Python is going to be hard

MRAB python at mrabarnett.plus.com
Wed Sep 3 14:24:38 EDT 2014


On 2014-09-03 19:10, Seymore4Head wrote:
> import math
> import random
> import sys
> b=[]
> steve = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
> for x in steve:
>      print (steve[x])
>
> Traceback (most recent call last):
>    File "C:\Functions\blank.py", line 7, in <module>
>      print (steve[x])
> IndexError: list index out of range
>
Iterating over a list yields its contents, not indexes.



More information about the Python-list mailing list