When would i want to use elif or how to use it
I am beginning to learn python and i am having trouble understanding when to use the elif statement.
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.
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
Link the repl if you have problems, I’m happy to help! :)