+ 1

nested ifs versus if / elif?

I’ve been doing another Python basics and encountered if - elif more often.... Nested ifs are quite weird for me.

11th Dec 2017, 12:03 AM
Maurien LeMaurien19
Maurien LeMaurien19 - avatar
3 Answers
+ 3
Nested if/else structure is logically equivalent to (and is compiled to the same bytecode as) elif. The latter is generally preferred as being more readable. https://stackoverflow.com/questions/44728436/difference-between-nested-if-else-and-elif
11th Dec 2017, 6:02 AM
David Ashton
David Ashton - avatar
+ 1
no different than nested ifs in excel
11th Dec 2017, 4:19 AM
manny
+ 1
Oh I see. Thank you guys!
11th Dec 2017, 6:03 AM
Maurien LeMaurien19
Maurien LeMaurien19 - avatar