Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #45322

IndexError: pop index out of range

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <formisc@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.016
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'pop': 0.05; 'main()': 0.09; 'val': 0.09; 'def': 0.12; '55,': 0.16; 'idx': 0.16; 'idx,': 0.16; 'indexerror:': 0.16; 'skip:" 70': 0.16; 'val,': 0.16; 'index': 0.16; 'examples': 0.20; 'print': 0.22; 'words': 0.29; 'errors': 0.30; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; '&quot;': 0.31; 'file': 0.32; '(most': 0.33; 'basic': 0.35; "can't": 0.35; 'received:google.com': 0.35; 'skip:& 10': 0.38; 'to:addr:python-list': 0.38; 'recent': 0.39; '\xa0\xa0\xa0': 0.39; 'to:addr:python.org': 0.39; 'range': 0.61; '8bit%:100': 0.72; '\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0': 0.84; 'skip:& 80': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:from:date:message-id:subject:to :content-type; bh=Hm1kS/pNEH7U2oULkpKaQWk3n8h2YR+9RWg/fdoSRhw=; b=iJD/gsXVT4CJnukYBhkFR/fqHj23p+JOyYCDa9etTUSm8tQT+DeTgarxF0J8qNWbIg 5duqax1ctgB180Gp9EuHgtcTpFDRkcJZwNG/0KB12qwHdovoAz7jQBgLwX2ZyqRHI4Be vad5nMlTmrelmHzQggx16E1PFym95Vsx0MuASVlbtNffqPYoKAUzPil2PsmN/wmD2Ylc hfhwnjVgd2TC0XJSkUrtFaTR2QeYGtzQT7KWMFr6/rzhJY+R+44ZQql+cHm8pK/gv2J3 WFZqhaWxwXjAPlN5hQBZA6Vhb4pn2pj/aTGmFoOh+DtF4tuA0f/eI827BRUFVs9+NHS5 hebg==
X-Received by 10.152.170.199 with SMTP id ao7mr16837694lac.51.1368591766013; Tue, 14 May 2013 21:22:46 -0700 (PDT)
MIME-Version 1.0
From Andrew Z <formisc@gmail.com>
Date Wed, 15 May 2013 00:22:05 -0400
Subject IndexError: pop index out of range
To python-list@python.org
Content-Type multipart/alternative; boundary=089e01176b290e4cd104dcba1a30
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1686.1368591775.3114.python-list@python.org> (permalink)
Lines 106
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1368591775 news.xs4all.nl 15914 [2001:888:2000:d::a6]:40172
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:45322

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

hello,
 going fru some basic examples and can't figureout why the following errors
out. Help is very much appreciated:
<code>
def front_x(words):
  # +++your code here+++
    print "words passed : ", words
    list_xx = []
    list_temp = words[:]
    print "list_temp -", list_temp
    print "words -", words
    for idx, val in enumerate(words):
        print val, idx
        # str_idx = val.find('x',0,2)
        if val[0] == 'x':
            vl = list_temp.pop(idx)
            list_xx.append(vl)

            print "appending list_xx", list_xx

    list_xx.sort
    list_temp.sort
    print "words sorted : " + str(words)
    print "list_temp sorted : ", list_temp
    list_xx.append(words)
    print "list_xx" + str(list_xx)
    return True

front_x
words passed : ['bbb', 'ccc', 'axx', 'xzz', 'xaa']
list_temp - ['bbb', 'ccc', 'axx', 'xzz', 'xaa']
words - ['bbb', 'ccc', 'axx', 'xzz', 'xaa']
bbb 0
ccc 1
axx 2
xzz 3
appending list_xx ['xzz']
xaa 4
Traceback (most recent call last):
  File
"/home/az/work/Python/Google_Course/google-python-exercises/basic/list1.py",
line 119, in <module>
    main()
  File
"/home/az/work/Python/Google_Course/google-python-exercises/basic/list1.py",
line 100, in main
    test(front_x(['bbb', 'ccc', 'axx', 'xzz', 'xaa']),
  File
"/home/az/work/Python/Google_Course/google-python-exercises/basic/list1.py",
line 55, in front_x
    vl = list_temp.pop(idx)
IndexError: pop index out of range

</code>

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

IndexError: pop index out of range Andrew Z <formisc@gmail.com> - 2013-05-15 00:22 -0400

csiph-web