+ 1

Python have switch or not??

21st Jun 2017, 2:08 PM
Asif Mohd
Asif Mohd - avatar
4 Answers
+ 9
No Because there is no need of it. Most languages have switch-case because they don't have proper mapping constructs. You cannot map a value to a function, that's why they have it. But in Python, you can easily have a mapping table(dict) where a certain value maps to a certain function.
21st Jun 2017, 2:20 PM
Cynth
Cynth - avatar
+ 2
The replacements in python are if/elif/else. You can also use a dictionary as an equivalent.
21st Jun 2017, 2:11 PM
Sapphire
+ 2
no se que tratas de decir :v
22nd Jun 2017, 4:54 AM
David Chaves Zarta
David Chaves Zarta - avatar
+ 1
do you speak uzbekian
22nd Jun 2017, 2:26 PM
Solijon Aliyev
Solijon Aliyev - avatar