[Tutor] if else
Alan Trautman
ATrautman@perryjudds.com
Wed, 22 May 2002 13:04:49 -0500
Python treats = the same way as C if that help but the way I think about it
is:
a = 1 means a is assigned the value of one
a == 1 a is equal to one
in your example
a = "python"
if a == "python" :
print "Yes"
else :
print "No"
will work where a is assigned the string "python"
and then is checked if it is equal to "python"
happy to have one I can answer
Peace
Alan
-----Original Message-----
From: Terje Johan Abrahamsen [mailto:terjeja@hotmail.com]
Sent: Wednesday, May 22, 2002 12:56 PM
To: tutor@python.org
Subject: [Tutor] if else
I try to use the if else statement. For example here:
a = "python"
if a = "python" :
print "Yes"
else :
print "No"
or
a = 1
if a = 1 :
print "Yes"
else :
print "No"
But, it doesn't work. When I try to run it, I get the following response:
"Failed to run script - syntax error - invalid syntax" What do I do wrong?
Thanks in advance,
Terje
_________________________________________________________________
Join the world's largest e-mail service with MSN Hotmail.
http://www.hotmail.com
_______________________________________________
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor