Advertisement
Advertisement


What is the Python equivalent for a case/switch statement?


Question

I'd like to know, is there a Python equivalent for the case statement such as the examples available on VB.net or C#?

2016/01/30
1
452
1/30/2016 1:15:55 PM


The direct replacement is if/elif/else.

However, in many cases there are better ways to do it in Python. See "Replacements for switch statement in Python?".

2017/05/23