0

elif

Basic question here, I'm currently on boolean- logic chapter and going over "and, or, not" and I noticed that when typing code certain codes will pull a syntax error if an "elif" is not used rather than a "if,else". So when do I know when to use "elif" rather then just waiting for an error?

4th Jan 2017, 12:17 AM
justin
2 Réponses
+ 5
elif is used when you already have an if . think about elif as a special else. And you cant have an else without a if
4th Jan 2017, 12:51 AM
Nahuel
Nahuel - avatar
0
You must use "if" first, if the condition is false you can set another condition using "elif". But remember "if" always comes first.
20th Jan 2017, 4:11 PM
Ricardo Bene
Ricardo Bene - avatar