+ 1
How i can use if else if
4 Answers
+ 3
It depends where to use but, the condition itself begins with if pay attention to indentation... for example
if something is true:
--do this---
elif something is true:
--do this---
else: (else working when above statements are wrong or didn't executed in other words.)
--do this--
The next way is using if -else condition statement in the if-else condition statement.
so here:
if something is true:
if another thing is true:
--- do this---
elif another thing is true:
--do this---
else:
-----do this-
elif something is true:
...etc... going in this way, so if you pay attention to indentation you will understand Hope this is helpful.
+ 2
Elif can be used to combine multiple if statements.
+ 1
if (X = 1):
print("yes, it is one.")
elseif (X = 2):
print("maybe")
elseif (X = 3):
print("no! You are wrong")
Going further to explain: python language provides if and else for decision making as i just did above. If (so so and so is TRUE) then wash Hair.
But if not TRUE, then don't wash Hair. Rather clean ROOM
+ 1
elif, not elseif.