Using set for Unique Elements in Python


Convert a list to a set to remove duplicate elements.

Source Code

my_list = [1, 2, 2, 3, 4, 4, 5]
unique_items = set(my_list)
print(unique_items)
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments