Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!nntp.club.cc.cmu.edu!micro-heart-of-gold.mit.edu!bloom-beacon.mit.edu!bloom-beacon.mit.edu!panix!gordon From: John Gordon Newsgroups: comp.lang.python Subject: Re: Python is going to be hard Date: Wed, 3 Sep 2014 18:17:27 +0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Lines: 31 Message-ID: References: NNTP-Posting-Host: panix3.panix.com X-Trace: reader1.panix.com 1409768247 20332 166.84.1.3 (3 Sep 2014 18:17:27 GMT) X-Complaints-To: abuse@panix.com NNTP-Posting-Date: Wed, 3 Sep 2014 18:17:27 +0000 (UTC) User-Agent: nn/6.7.3 Xref: csiph.com comp.lang.python:77486 In Seymore4Head 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 > 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. -- John Gordon Imagine what it must be like for a real medical doctor to gordon@panix.com watch 'House', or a real serial killer to watch 'Dexter'.