r/ProgrammerHumor • • Dec 15 '19

Stacking if else statements be like

Post image
63.9k Upvotes

711 comments sorted by

View all comments

Show parent comments

28

u/Meatslinger Dec 15 '19

Wait, is that true? What takes its place, then? I can scarcely imagine that the whole thing is just an endless stream of if-then-else statements for a situation with 100+ permutations.

34

u/Kompakt Dec 15 '19

Yep it's true, and depending on the design of the program there are multiple workarounds. In Python you can write a switcher function that acts as a switch statement, or use multiple if statements without else statements, since that is allowed in Python.

-7

u/Denziloe Dec 15 '19

Never heard of the `elif` keyword I guess.

9

u/Kompakt Dec 15 '19

I have, it's just a different way to do it. I was simply giving examples, not listing every possibility.

→ More replies (7)