可以通過以下兩種方法刪除列表中的重復元素:
my_list = [1, 2, 3, 3, 4, 5, 5, 6]
new_list = list(set(my_list))
print(new_list)
輸出結果:[1, 2, 3, 4, 5, 6]
my_list = [1, 2, 3, 3, 4, 5, 5, 6]
new_list = []
[new_list.append(x) for x in my_list if x not in new_list]
print(new_list)
輸出結果:[1, 2, 3, 4, 5, 6]