frustrating failure of 'break' statement ( novice )

Mark Dickinson dickinsm at gmail.com
Sat Jun 13 18:07:10 EDT 2009


On Jun 13, 10:48 pm, pdlem... at earthlink.net wrote:
> In my programs the 'break' fails to work.  I've studied the docs for
> 3.0 and Programming in Python, neither of which are illuminating.
> Simplest example :
>
> while True :
>     num = int(input())
>     print(num)
>     if num == 0 :
>         break
>
> print('done')
>
> SyntaxError : invalid syntax    ( pointing to end of break )
> [...]

Are you mixing tabs and spaces in your code at all?  Check that the
'break' line is indented with 8 spaces rather than a tab character.

Mark



More information about the Python-list mailing list