Your "for idx, val in enumerate(words):" is running on words not list_temp.
As you remove from list_temp and keeps parsing words you get the IndexError.
________________________________
> From: form...@gmail.com
> Date: Wed, 15 May 2013 00:22:05 -0400
> Subject: IndexError: pop index out of range
> To: python-list@python.org
>
> 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>
>
> -- http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list