我試圖找到最少的數字,您可以輸入儘可能多的數字,當您輸入-1時,它會中斷。尋找最小編號
a=int(input("What is your number of choice? "))
b=int(input("What is your number of choice? "))
c=int(input("What is your number of choice? "))
d=int(input("What is your number of choice? "))
smallest=a
if (b < smallest):
smallest=b
while(True):
smallest =int(input("What is your number of choice? "))
if (smallest == -1):
break
if (c < smallest):
smallest=c
while(True):
smallest =int(input("What is your number of choice? "))
if (smallest == -1):
break
if (d < smallest):
smallest=d
while(True):
smallest =int(input("What is your number of choice? "))
if (smallest == -1):
break
print(smallest, " is smallest of the numbers you chose")
我找不出如何解決它。
你沒有使用'min'功能的原因? –
a' - '字符不是整數 – smoggers
如果對所有輸入使用函數int(),如何在函數min中獲得此異常? –