Python is going to be hard
Rob Gaddi
rgaddi at technologyhighland.invalid
Wed Sep 3 14:19:04 EDT 2014
More information about the Python-list mailing list
Wed Sep 3 14:19:04 EDT 2014
- Previous message (by thread): Python is going to be hard
- Next message (by thread): Python is going to be hard
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Wed, 03 Sep 2014 14:10:42 -0400 Seymore4Head <Seymore4Head at Hotmail.invalid> 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 You're failing to go through the basic tutorials, and blaming the language when you don't understand things. 'for x in steve' does not sweep x over the indices of steve. 'for x in steve' sweeps x over the sequential _values_ in steve. This would have been clear if you were to add a print(x) into the loop. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix.
- Previous message (by thread): Python is going to be hard
- Next message (by thread): Python is going to be hard
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list