[Pythonmac-SIG] Whats the invalid syntax about

skip at pobox.com skip at pobox.com
Sun May 31 21:09:43 CEST 2009


    >> please suggest what could have gone wrong here why am i getting a
    >> syntax error

It's a quirk of the interactive interpreter.  To terminate a loop you need a
blank input line:

    >>> some_list = [3,6,2,5]
    >>> i = 1
    >>> while i < 3:
    ...   print some_list[i], ";"
    ...   i = i + 1
    ... 
    6 ;
    2 ;
    >>> print some_list[3]
    5

-- 
Skip Montanaro - skip at pobox.com - http://www.smontanaro.net/
    America's vaunted "free press" notwithstanding, story ideas that expose
    the unseemly side of actual or potential advertisers tend to fall by the
    wayside.  Not quite sure why.  -- Jim Thornton


More information about the Pythonmac-SIG mailing list