On Sat, 13 Jun 2009 22:48:43 +0100, <pdlem...@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 ) This happens whether the 'break' is put on same line as the conditional, flush with while, flush with if, or appropriately indented 4 spaces.
It works for me, running it from file. It fails with "invalid syntax" (pointing to the end of *print*) if I cut and paste the program exactly into a Python shell, presumably because the shell gets unhappy about having more command input when it wants to be executing the while loop. Does this match what you see? -- Rhodri James *-* Wildebeest Herder to the Masses -- http://mail.python.org/mailman/listinfo/python-list