If Statements
Syntax
if condition:
# run if condition is true
elif another_condition:
# run if previous conditions were false
else:
# run if all conditions were falseExample
x = 10
if x < 0:
print("Negative")
elif x % 2 != 0:
print("Positive and odd")
else:
print("Even or zero")Truthiness
Common Pitfalls
Practice
Last updated