About 55 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 want to know about …

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

    Sep 13, 2008 · I want to write a function in Python that returns different fixed values based on the value of an input index. In other languages I would use a switch or case statement, but Python does not …

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

    Mar 30, 2021 · With Python, there are some differences to note though. Cases don't fall through It's common that languages with switch - case statements execute every case the value matches - from …

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

    Mar 15, 2021 · Switch-case statement in Python Asked 5 years ago Modified 5 years ago Viewed 3k times

  5. Why doesn't Python have switch-case? (Update: match-case syntax was ...

    Oct 12, 2017 · Please explain why Python does not have the switch-case feature implemented in it.

  6. Есть ли в Python оператор switch case? - Stack Overflow на русском

    Столкнулся с тем, что требуется реализовать множественное условие, которое в других языках я бы реализовал с помощью конструкции switch-case. В Python мне приходится расписывать всё …

  7. How to use multiple cases in Match (switch in other languages) cases in ...

    Oct 20, 2021 · How to use multiple cases in Match (switch in other languages) cases in Python 3.10 Ask Question Asked 4 years, 5 months ago Modified 2 years, 8 months ago

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

    I'd like to create a switch/case where the cases can have intervals as condition, like: switch = { 1..<21: do one stuff, 21...31: do another } How can I achieve this result?

  9. python - Continue to match next case after match? - Stack Overflow

    Feb 28, 2023 · According to the official Python documentation (PEP 636), once the first matching pattern is found, the body of that case is executed, and all further cases are ignored. Therefore, C-style fall …

  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 how I …