Discuss / Python / 笨办法

笨办法

Topic source

拿笔小星

#1 Created at ... [Delete] [Delete and Lock User]
if len(L) == 0:
    return (None, None)
elif len(L) == 1:
    return (L[0], L[0])
else:
     min = 0
     max = 0
     if L[0] > L[1]:
         min = L[1]
         max = L[0]
     else:
         min = L[0]
         max = L[1]

     for i in L:
        if i > max:
            max = i
        if i < min:
            min = i
     return (min, max)

  • 1

Reply