2012-10-05 62 views

回答

2

使用

mini = scores[0] 

而不是0

0
scores = [1, 2, 3, 4, 5] 

所有這些都將工作:

sorted(scores)[0] 
sorted(scores, reverse=True)[-1] 
[s for s in scores if all(s<=i for i in scores)][0] 

def getMin(L): 
    answer = L[0] 
    for i in L: 
     if i < answer: 
      answer = i 
    return answer 
getMin(scores) 
相關問題