2014-02-13 63 views
-1
list = "\n==== Names and Distances ====\n" 
firstName = input ("Enter next person's first name >") 
while firstName > "": 
    distance= float(input("Enter distance thrown: ")) 
    lastName = input ("What is "+firstName+"'s last name?") 
    list = list + firstName[0] + "." + lastName + str(distance) + "\n" 
    firstName = input ("Enter next person's first name >") 
    high=float(max(distance)) 
    low=float(min(distance)) 
print (list) 
print ("The furthest distance is: " + high) 
print ("The shorest distance is: " + low) 

我得到錯誤'浮動'對象不可迭代。我很好奇我做錯了什麼,如果我在編寫這段代碼的時候完全不瞭解。浮點對象不可迭代

+1

你期望'max(distance)'做什麼?你給它提供了一個單一的號碼......你認爲它會告訴你這個號碼是什麼? 'min(distance)'相同。 – kindall

回答

2

您正嘗試對單個值調用max()min()。首先將值存儲在列表中,然後調用它們。