else in python 3 code example
Example 1: if syntax in python
variable_name = input("y/n? >> ")
if variable_name == "y":
print("That's good! :) ")
elif variable_name == "n":
print("That's bad! :( ")
else:
print("You blow up for not following my instructions. Detention forever and get lost!")
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: else if python
word = input('Word: ')
if word == 'hello':
print('world')
elif word == 'world':
print("Hey, that's my line >:(")
else:
print("Hey buster you gonna say hello or not?")