def Bubble(L):
x = L.copy()
for j in range(len(x)):
for i in range (len(x)-1):
firstnumber = x[i]
secondnumber = x[i+1]
if x[i] > x[i+1]:
x[i] = secondnumber
x[i+1] = firstnumber
return x
def Max(L):
print(L.Bubble[len(L)-1])
def Min(L):
print(L.Bubble[0])
我试图在使用 Bubble 对列表进行排序后定义列表的最大值和最小值,但每次运行它时,我都会得到:
AttributeError: 'list' object has no attribute 'Bubble'