2012-04-15 4 views
0

私は作業しているアプリケーションを持っていますが、今はこの行をPythonに変換する必要があります。数highvalueの21よりも大きい、lowValueを返し、それが21より低い場合、highvalueのを返す場合シンプルなObj-CをPythonに変換する

return (highValue > 21) ? lowValue : highValue; 

上記は言います。どのように私はこれをPythonに変換できますか?

ありがとうございます!

答えて

3

私はあなたにも、ここでpython-ternary-operatorを見てみましょう

>>> highvalue = 25 
>>> lowvalue = 21 
>>> def myfunc(): 
...  return lowvalue if highvalue>21 else highvalue 
... 
>>> myfunc() 
21 
>>> 

を探していると信じています。

+0

これです!ありがとうございました!今私はこれらのことが何であるか知っています! – Alec

+0

@AlecK。ようこそ。ハッピーコーディング。 – RanRag

関連する問題