[Tutor] function error
Steve Willoughby
steve at alchemy.com
Sat Oct 2 19:45:43 CEST 2010
On 02-Oct-10 10:32, Emile van Sebille wrote:
>> File "my_turtle.py", line 19
>> if (abs(turtle.position()[0])> turtle.window_height()/2) or
>> ^
>> SyntaxError: invalid syntax
How does Python know that the next line is the continuation of your if
statement, instead of the beginning of a new line of code? You didn't
do anything to indicate continuation, so it takes this as an incomplete
statement. "If ... stuff ... or... (or what??)"
You need to END that line with a backslash
if (abs(...height()/2) or \
...continuation...:
or else make the line break INSIDE a set of parentheses, for Python to
keep looking to the next line(s) to complete the statement.
More information about the Tutor
mailing list