Is there a Switch CASE operator in Python?
📁 python, вопрос, помощь, проект
I faced the fact that it is necessary to implement a multiple condition that in other languages I would implement using the design & nbsp;
in python, I have to sign everything through Conditions & NBSP;
is there a more convenient way to recording such conditions?
nfor example, I have units of measurement and depending on the selected I need to retu the corresponding factor:
n Def get_multiplier ( unit ): n if unit == 'mm' : n retu 10 **- 3 n if unit == '' cm ': n Retu 10 **- 2 n if unit == 'dm' : n retu 10 **- 1 n f unit == 'm' : n retu 1 n if unit == 'Km' : n retu 10 ** 3 n raise valueroror ( 'undefined unit: {}' . format (unit)) n n Ответов пока нет.
Войдите чтобы оставить ответ