largest = None
smallest = None
while True:
num = input("Enter a number: ")
if num == "done":
break
try:
inp = int(num)
except:
print("Invalid Input")
continue
if largest is None or num > largest:
largest = inp
if smallest is None or num < smallest:
smallest = inp
print("Maximum is", largest)
print("Smallest is", smallest)
答案 0 :(得分:0)
当你从输入法中找回一个数字时,它是&#34; str&#34; 例如:
>>> num = input("enter num:")
enter num:5
>>> type(num)
<class 'str'>
你通过写作来解决这个问题
num = int(num)