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 regex to find sequences of one upper case letter followed by lower case letters
- Python program to convert camel case string to snake case
- Python - Convert Snake case to Pascal case
- Python - Convert Snake Case String to Camel Case
- Python - Random Replacement of Word in String
- Python - Character Replacement Combination
- Python | Switch widget in Kivy
- Python | Switch widget in Kivy using .kv file
- Tkinter Application to Switch Between Different Page Frames
- Python program to count upper and lower case characters without using inbuilt functions
- Python | Toggle characters in words having same case
- Python | Convert case of elements in a list of strings
- Python | Ways to sort list of strings in case-insensitive manner
- Python | Case Counter in String
- Python - Extract Upper Case Characters
- Python - Case Insensitive Strings Grouping
- Python - Specific case change in String List
- Python - Change Keys Case in Dictionary
- Convert string to title case in Python
- Case-insensitive string comparison in Python