There are several ways to remove duplicates from a list in Python. Here are a few methods:
my_list = [1, 2, 3, 3, 4, 5, 5, 6]
my_list = list(set(my_list))
print(my_list) # Output: [1, 2, 3, 4, 5, 6]
my_list = [1, 2, 3, 3, 4, 5, 5, 6]
new_list = []
for item in my_list:
if item not in new_list:
new_list.append(item)
print(new_list) # Output: [1, 2, 3, 4, 5, 6]
my_list = [1, 2, 3, 3, 4, 5, 5, 6]
new_list = [item for item in my_list if item not in new_list]
print(new_list) # Output: [1, 2, 3, 4, 5, 6]
These are some commonly used methods for removing duplicates from a list in Python. Choose the method that best suits your needs and the complexity requirements of your program.