Ask coding questions

← Back to all posts
Does Python have an equivalent to Haxe switch cases?
aflacc

I do a lot of programming in Haxe, which is honestly one of my favorite coding languages because of how easy it is to get used to. And one of the things I use the most in Haxe is these things called switch cases. Here's an example:

It's basically a really compact way of checking if a variable matches several values.

I'm wondering if Python has an equivalent to the Switch case or if I have to stick to messy if statements.

Answered by Coder100 [earned 5 cycles]
View Answer
Voters
aflacc
Comments
hotnewtop
Coder100

python does not.
you can in a way make a 'switch'

VulcanWM

You can try using if statements