If elif else condition

no1 = int(input(“Enter your first no.”))
no2 = int(input(“Enter your second no.”))
no3 = int(input(“Enter your third no.”))

if no1 > no2 and no2 > no3:
print(no1,‘no1 is the greatest’)
elif no2 > no1 and no2 > no3:
print(no2,‘no2 is greatest’)
else:
print(no3,‘no3 is greatest’)

if i give input no1=10,no2=20,no3=30
then if condition is not printing instead its printing else condition
why it is so…please explain

1 Like

@thaseenraza1210
in first line no1>no2 and no1>no3 must be there because here we’re checking whether no1 is greater than no2 as well as no1 is greater than no3

2 Likes

its because ,you gave 10>20 and 20>30 which is false and second condition is 20>10 and 20>30which is also false, so it give you 30 is greatest . both if and elif are not satisfying , so else will print

1 Like