Using Dictionary For Switch Case Statement in Python

preview_player
Показать описание
A lot of languages have a switch / case statement that works like a slightly cleaner version of chained-up if, else if statements. Some people who love switch lament the lack of it in Python, but it is because there is a much more "Pythonic" approach using the super-versatile dict object.
Рекомендации по теме
Комментарии
Автор

Hey if any of you Pythonistas envy the switch / case statement from other languages, envy no more. Did you know that the common dictionary object provides an elegant and Pythonic equivalent to switch/case? It does!

MikeLevin
Автор

wow dude you needed over 8 min for that

Turjak_art
welcome to shbcf.ru