[Solved] What is different if and elif? [duplicate]


It’s different.

It basically else if but concated to elif. if you use elif you check the same condition and if one is met it exits.

If you use ifs the whole time it checks each if statement whether or not the previous one was true.

It’s just normal Python Syntax.

x = 0
if x == 0:
#do something
#if True it doesn't check the rest
elif x ==1:
#do something
#if true if doesn't check the rest
elif x==2:
#do something
#if true doesn't check the rest
else:
#if none of these are True this gets exucuted
#do something

#It checks all these if statements whether or not one is true. 
if x==1:
#do something 
if x==2:
#something

2

solved What is different if and elif? [duplicate]