and in python if statement code example
Example 1: python if statement
usrinput = input(">> ")
if usrinput == "Hello":
print("Hi")
elif usrinput == "Bye":
print("Bye")
else:
print("Okay...?")
Example 2: how to use an if statement in python
x = True
if x == True:
print("x is true")
elif x == False:
print("x is false")
else:
print("x is neither true nor false")
Example 3: or statement python
if x==1 or y==1:
print(x,y)
Example 4: python if and
if foo == 'abc' and bar == 'bac' or zoo == '123':
Example 5: 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 6: else if python
if (condion):
result
elif (condition):
results
else:
result