我有一个应用程序,我一直在努力,但现在我需要将此行转换为Python。
return (highValue > 21) ? lowValue : highValue;
如果数字highValue大于21,则返回lowValue,如果低于21,则返回highValue。如何将其转换为Python?
谢谢!
答案 0 :(得分:3)
我相信你在寻找
>>> highvalue = 25
>>> lowvalue = 21
>>> def myfunc():
... return lowvalue if highvalue>21 else highvalue
...
>>> myfunc()
21
>>>