[Tutor] loop example from 'Learning to Program'

Luke Paireepinart rabidpoobear at gmail.com
Mon Jul 16 00:39:05 CEST 2007


ron wrote:
> ok, this code is written with vi:
>
> #/usr/bin/env python
>   
This should be #! not just #, that makes it a regular comment.
> #foreach.py
>
> myList = [1,2,3,4]
> for index in range(len(myList)):
>         myList[index] += 1
> print myList
> ~
>
> here's the result:
>
> ~$ ./foreach.py
>   
You have to run the code like this:
python foreach.py
So that python is executing the code instead of bash.
HTH,
-Luke


More information about the Tutor mailing list