Python Problem I | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Python Problem I

I just encountered some differences involving conditional statements on Python and other languages. Why do you think Python has no switch statements? Thanks for any response that you make.

7th Jul 2020, 2:10 AM
James Clark I. Vinarao
James Clark I. Vinarao - avatar
2 Answers
+ 4
James Clark I. Vinarao there has been several proposals for switch case in python but there are several reasons as to why switch case failed in testing. Here is the pep notes regarding switch case and alternatives https://www.python.org/dev/peps/pep-3103/
7th Jul 2020, 3:13 AM
BroFar
BroFar - avatar
+ 5
Python doesn't have a switch statement. Although, you can use dictionary mapping: https://www.geeksforgeeks.org/switch-case-in-python-replacement/
7th Jul 2020, 2:22 AM
A C K
A C K - avatar