135k views
0 votes
How to implement switch statement in Python?

2 Answers

2 votes
Make sure there is a function/method to handle the default case. Next, make a dictionary object and store each of the function beginning with the 0th index. After that, write a switch() function accepting the day of the week as an argument.
User Dominik Schrempf
by
4.9k points
2 votes

Answer:

Switch-case statements are a powerful tool for control in programming. In this article, Sreeram Sceenivasan goes over you can use a switch-case statement in Python.

Step-by-step explanation:

Python doesn’t need a switch statement. You can do exactly the same thing with if/elif/else statements.

User Gravelpot
by
5.4k points