for if else python code example
Example 1: python if statement
usrinput = input(">> ")
if usrinput == "Hello":
print("Hi")
elif usrinput == "Bye":
print("Bye")
else:
print("Okay...?")
Example 2: python for else
list = [99, 98, 97, 96, 95, 94]
for number in list:
if number == 2:
print("There is a 2 in the list")
break
else:
print("There are no 2's in the list")
# The else statement is only reached if the for loop
# has run all the way through without breaking
Example 3: if statement python
x=1; y=0; z=0;
if x==1 or y==0:
if z=0 and x=1:
print('Useless conditions satisfed!')