Python Practice › Set Programs › Program 12
List to a set
Write a Python program to convert a list to a set.
Input
[4, 2, 4, 9, 2]
Output
{9, 2, 4}Approach
set(list)removes duplicates.
Solution
print(set([4, 2, 4, 9, 2]))Output
{9, 2, 4}Learn the concept
New to this topic? Read the lesson, then come back.