#方法一:利用集合去重
list_1=[10, 1, 2, 20, 10, 3, 2, 1, 15, 20, 44, 56, 3, 2, 1]
def func1(list_1):
"""利用集合去重..."""
return list(set(list_1))
print('去重后的列表:',func1(list_1))
#[1, 2, 3, 10, 44, 15, 20, 56]
#方法二:...56, 3, 2, 1]
def func2(list_2):
"""利用列表的推导式"""
#定义一个空列表
mylist_2=[]
#i遍历list_2
for...方法排序,默认是升序
list_3 = [10, 1, 2, 20, 10, 3, 2, 1, 15, 20, 44, 56, 3, 2, 1]
def func3(list_3):
"""
使用排序的方法...]
#方法四
list_4= [10, 1, 2, 20, 10, 3, 2, 1, 15, 20, 44, 56, 3, 2, 1]
def func4(list_4):
"""
使用字典的方式