# 用 for i in 來迭代遍歷來去除列表中的重複的數據
list1 = [100,111,111,222,888,888,333,444,555,666]
list2=[]
for i in list1:
if i not in list2:
list2.append(i)
print(list2)
#使用set函數,但只有不關注排序時使用
list3=set(list1)
print(list3)
#max()函數也可以得出列表中的最大值
print(max(list1))
#print(min(list1)) ,min()函數也可以得出列表中的最小值
#用for n in 來迭代遍歷也可以得出最大值
a = list1[0]
#print(a)#以列表的第0個元素開始
for n in list1:
if a a=n print(a) #反過來也可以求最小值,只需要修改a>n
閱讀更多 Python學長 的文章