[Tutor] loop example from 'Learning to Program'

ron rondosxx at yahoo.com
Mon Jul 16 00:20:16 CEST 2007

So I'm starting to work my way through Alan's online
book, reading, then typing in code and seeing it work.
The following is a snippet of code in the Loops
section. I'm getting an error message.

Here's the code and error message:

 myList = [1,2,3,4]
 for index in range(len(myList)):
    myList[index] += 1
 print myList

  File "<stdin>", line 3
    print myList
SyntaxError: invalid syntax

can someone tell me what the syntax error is, and how
to correct it?

my thanks, ron

Looking for a deal? Find great prices on flights and hotels with Yahoo! FareChase.

More information about the Tutor mailing list