[Tutor] basic python question
Ron Nixon
nixonron@yahoo.com
Fri, 20 Sep 2002 07:17:28 -0700 (PDT)
--0-1167826968-1032531448=:17914
Content-Type: text/plain; charset=us-ascii
I'm playing around with the "How to Think Like A Computer Scientist" book and trying one of the examples and I keep getting syntax errors even though I'm typing word for word.
if X%2==0:
print x, "Is even"
else:
print x, "is odd"
but I get a syntax error on the "else:" as shown below. Can I not do this with IDLE?
SyntaxError: invalid syntax
>>> if x%2==0:
print x, "is even"
else:
SyntaxError: invalid syntax
>>>
---------------------------------
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
--0-1167826968-1032531448=:17914
Content-Type: text/html; charset=us-ascii
<P>I'm playing around with the "How to Think Like A Computer Scientist" book and trying one of the examples and I keep getting syntax errors even though I'm typing word for word.
<P>
<P>if X%2==0:
<P>print x, "Is even"
<P>else:
<P>print x, "is odd"
<P>
<P>but I get a syntax error on the "else:" as shown below. Can I not do this with IDLE?
<P>
<P>SyntaxError: invalid syntax<BR>>>> if x%2==0:<BR> print x, "is even"<BR> else:<BR> <BR>SyntaxError: invalid syntax<BR>>>>
<P>
<P> </P><p><br><hr size=1>Do you Yahoo!?<br>
New <a href="http://rd.yahoo.com/evt=1207/*http://sbc.yahoo.com/">DSL Internet Access</a> from SBC & Yahoo!</a>
--0-1167826968-1032531448=:17914--