What is 'elif' and when do I use it?

Asked by blessing007 · 6 months ago

1 Answer

50
amorebise · 6 months ago Top Answer

elif is short for 'else if'. It’s like saying: "If I have 500 Naira, I'll buy suya. Else if I have 200, I'll buy chin-chin. Otherwise, I'll just drink water."

It allows you to check many different conditions one after the other. Python will stop as soon as it finds one that is true. It’s very efficient.

Log in to add a comment.