Python is going to be hard

Seymore4Head Seymore4Head at Hotmail.invalid
Wed Sep 3 20:52:56 CEST 2014


On Wed, 3 Sep 2014 18:17:27 +0000 (UTC), John Gordon
<gordon at panix.com> wrote:

>In <d9me0ap5s0s28qaeobbh6680gciel6c1og at 4ax.com> Seymore4Head <Seymore4Head at Hotmail.invalid> writes:
>
>> import math
>> import random
>> import sys
>
>Why are you importing these modules if they're not used?
>
>> b=[]
>
>Likewise b is not used.
>
>> steve = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
>> for x in steve:
>>     print (steve[x])
>
>As you step through the loop, x becomes each successive item in the 'steve'
>list.  Therefore, you probably want to print just plain x, not 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
>
>There are fewer than 13 items in steve, so when x reaches 13 this error
>pops up.

I see that now.
Thanks



More information about the Python-list mailing list