Basics II 3. Conditional statements
Conditional statements
Use if, elif, and else to branch your code.
x = 2
if x < 2:
print("x is less than 2")
elif x == 2:
print("x is exactly 2")
else:
print("x is greater than 2")
More examples
s = "python"
if s == "python":
print("Match!")
langs = ["Python", "Java", "C++"]
if "Python" in langs:
print("Found Python!")