Skip to content
← Back to Community
When would i want to use elif or how to use it
Profile icon
StupitTurtle

I am beginning to learn python and i am having trouble understanding when to use the elif statement.

Voters
Profile icon
StupitTurtle
Comments
hotnewtop
Profile icon
StupitTurtle

Thanks it helped me alot

Profile icon
SixBeeps

It's for chaining if statements together so that only one of the conditions runs. I can't think of a good example right now, but it's useful for when you want to use if statements, but you want only one of them to run.

Profile icon
Bookie0

So the elifstatement comes after the ifstatement. For example:

Age = input(“what is your age?”) if Age == “10”: print(“you are 10”) elif Age == “12”: print(“you are 12”)

So basically the elif is kinda like the if

Link the repl if you have problems, I’m happy to help! :)