Switch Case in Python 🤔 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Switch Case in Python 🤔

How can i use switch case in python?, Is there any alternetive? Because using if else so many times will increase the time complexity of the program.

20th Nov 2018, 6:30 AM
Rishabh Sikarwar
Rishabh Sikarwar - avatar
3 Answers
+ 2
Ha yes there is an alternative for swich case,,,,you can use "while for condition statement(switch),and use if,elif statements for case(labels in switch),at the end use else statement for default (default statement in switch),,,,
21st Nov 2018, 9:55 AM
Niveditha Javaniki
Niveditha Javaniki - avatar
0
Rishabh Sikarwar , Python 3.10 added the match case syntax. Sololearn still uses Python 3.9.16. https://peps.python.org/pep-0636/
14th Nov 2023, 1:40 AM
Rain
Rain - avatar