DAY 22 of PYTHON top 100 questions : from Basic to Advanced !!

DAY 22 of PYTHON top 100 questions : from Basic to Advanced !!

Write a Python program to remove duplicates from a given list:

l=[2,3,4,5,6,4,2]
print(list(set(l)))
Output :
[2, 3, 4, 5, 6]

The code provided will remove duplicate elements from the list l and print the result.

The set() function is used to create a set, which is an unordered collection of unique elements. By converting the list to a set, duplicates are automatically removed because sets only store unique values. Then, list() is used to convert the set back to a list, and the resulting list is printed.


If you are a beginner and want to know more about Python programming, you can read my Basics of Python blogs (From part 1 to part 15).


HAPPY LEARNING !!!