- If, Elis, & Else Statements
- Allow user to use logic to execute code when a particular condition has been met
- The keywords to control the flow of logic
- Syntax of an if statement:
- if some_condition: then execute some code
- Syntax of an if/else statement:
- if some_condition: then execute some code
- elif some_other_condition: then do something different
- else: do something else
- Examples:
location = "Bank"
if location == "Auto Shop":
print("Cars are here!")
elif location == "Bank":
print("Bank is here!")
elif loc == "Store":
print("Store is here!")
else:
print("Not sure!")
Bank is here!
if True:
print("It's true")
It's true