0
Why does python not have "switch" statement
We all are know that switch statement is best alternative of "elif" statement
2 Answers
+ 5
In Python we use dicts instead:
https://www.geeksforgeeks.org/switch-case-in-python-replacement/
+ 4
Python doesn't have a switch statement simply because it would have been difficult to implement it into the language provided the syntax used and how Python would need to run something like it. With the language, there is no way to assign a constant variable, so the developers found it difficult to implement it. Also, either way it merely does the same as an if/elif/else chain so there really would be no need to add something unnecessary that can be easily worked around (I personally like the if/elif/else chain better because the syntax makes be better satisfied that my code will do what I want it too).
These posts can also help a little:
https://stackoverflow.com/questions/46701063/why-doesnt-python-have-switch-case
https://www.sololearn.com/Discuss/48633/?ref=app



