March 11, 2009

Python IF Statements

if variable == "hello":
print "your variable equalled: hello"
elif variable == "goodbye":
print "your variable equalled: goodbye"
else:
print "your variable equalled something else"
----------------------------------------------------

the "if" checks the variable to see whether or not its value is "hello".
if the value is "hello" then it prints "your variable equalled: hello"
the "elif" is basically another if statement.  elif your variable equalled goodbye then it prints "your variable equalled: goodbye"

No comments:

Post a Comment