About 225,000 results
Open links in new tab
  1. What is the Python equivalent for a case/switch statement?

    Jul 14, 2012 · Python 3.10.0 provides an official syntactic equivalent, making the submitted answers not the optimal solutions anymore! In this SO post I try to cover everything you might …

  2. Replacements for switch statement in Python? - Stack Overflow

    Sep 13, 2008 · 2241 Python 3.10 (2021) introduced the match - case statement, which provides a first-class implementation of a "switch" for Python. For example:

  3. What is the syntactical equivalent to switch/case in Python?

    Mar 30, 2021 · Important Notices If coming from languages which support switch and case, it's likely that you already know about their behavior. With Python, there are some differences to …

  4. menu - Switch-case statement in Python - Stack Overflow

    Mar 15, 2021 · I found that I can use dictionary and get () method, it's working fine, but I should use if else statement after get () to execute a function that answers the user choice.

  5. Using a dictionary as a switch statement in Python

    Feb 23, 2014 · Using a dictionary as a switch statement in Python [duplicate] Asked 11 years, 10 months ago Modified 4 years ago Viewed 42k times

  6. python match case part of a string - Stack Overflow

    Nov 9, 2022 · 9 In match statement, strings are compared using == operator which means that case patterns must be exactly equal to the match expression (mystring in this case) . In order …

  7. python - How to create a switch case with the cases being intervals ...

    1 If you really have to use switch/case, then dictionary in Python can help you with that. Is there a way for a dictionary key be a range? This is my take on it:

  8. Is there any value to a Switch / Case implementation in Python?

    Mar 27, 2011 · Recently, I saw some discussions online about how there is no good "switch / case" equivalent in Python. I realize that there are several ways to do something similar - …

  9. I want to make calculator using switch case statement in python

    Jul 22, 2019 · I am able to make calculator using the If and elsif statement but I am unable to make it with the switch case statement. I create basic for switch case but I stacked in how to …

  10. How to write a nested switch case in python? - Stack Overflow

    Nov 21, 2019 · I am working on the python project in which I needed to implement nested switch. This answer helped me a lot. Here is working example based on that answer. The example is …