私は以下のコードを書いてpythonで実行しようとしましたが、私は= 56 b = 67として入力を与えればうまく動作しますが、 789、B = 45566 -Pythonでif条件の2つのintegeres buの使用を比較する
以下A = 789、B = 45566が入力された場合、コード
def max(a,b):
if a>b:
print(a+" is greater than "+b)
else:
print(b +" is greater than "+ a)
o1 = raw_input("Enter value of A ")
o2 = raw_input("Enter value of B ")
to = max(o1,o2)
書き込ま出力されている - の値を入力B 45566の値を入力してください 789は45566より大きく
の入力のためであるのに対し、raw_inputは、文字列型の入力用ですので
。 – syntonym
'to = max(o1、o2)'を 'to = max(int(o1)、int(o2))'に変更します。 – MicroPyramid
'type'を使って変数の型をチェックすることを習慣にします。 – hashcode55