else if in python 3 code example
Example 1: if else python
print('What is age?')
age = int(input('number:'))
if age > 18:
print('go ahead drive')
elif age == 18:
print('come personaly for test')
else:
print('still underage')
Example 2: if statement in python
answer = input(":")
if answer == "lol":
print("haha")
else:
print("not haha")
exit()
please note that the exit() command is optional and is not necessary.
Example 3: python if elif
num = 20
if num > 30:
print("big")
elif num == 30:
print("same")
else:
print("small")
Example 4: if else python
if condition:
result
elif condition:
result
else:
result
Example 5: else if python
name = input("What's your name? \n")
if name == "Aguy12":
print("Wait a second...")
elif name == "Aguy11":
print("Now that's definitely not true")
else:
print(f"Hello, {name}!")