What is the replacement of Switch Case in Python ?
Unlike every other programming language we have used before, Python does not have a switch or case statement. To get around this fact, we use dictionary mapping.
This code is analogous to given code in C++ :
This article is contributed by Shashank Mishra (Gullu). If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Python program to convert camel case string to snake case
- Python regex to find sequences of one upper case letter followed by lower case letters
- Python | Switch widget in Kivy
- Python | Switch widget in Kivy using .kv file
- Python | Case Counter in String
- Python - Case Insensitive Strings Grouping
- Python | Toggle characters in words having same case
- Python - Extract Upper Case Characters
- Python | Convert case of elements in a list of strings
- Python | Ways to sort list of strings in case-insensitive manner
- Python program to count upper and lower case characters without using inbuilt functions
- Important differences between Python 2.x and Python 3.x with examples
- Python | Convert list to Python array
- Python | Index of Non-Zero elements in Python list
- Reading Python File-Like Objects from C | Python