Avatar ·

Is there a Switch CASE operator in Python?

📁 Advanced Python Topics, question, Help, project

I faced the fact that it is necessary to implement a multiple condition that in other languages I would implement using the switch-case construct

In Python, I have to write everything through if -elif -else conditions. This seems quite inconvenient to me.

Is there a more convenient way to write such conditions?

For example, I have units of measurement and depending on the selected one I need to return the corresponding factor:

   Def   get_multiplier  ( unit ):