Why 5 is greater than 10 python?
问题 while True: x = input().split() if len(x) != 2: continue a, b = x if a > b: print(a, 'is greater than', b) Hi, why when i input: '5 10', output: '5 is greater than 10'? 回答1: in python all that's returned from input are strings, and they are still strings even after you use split() on them. '5' (the string) is larger than '10' (the string) because string comparison works on the first letter first! To do it properly, convert them both to int : while True: x = input().split() if len(x) != 2: