DEV Community

Nilotpal Choudhury
Nilotpal Choudhury

Posted on

Answer: Get unique values from a list in python [duplicate]

First declare your list properly, separated by commas. You can get the unique values by converting the list to a set.

mylist = ['nowplaying', 'PBS', 'PBS', 'nowplaying', 'job', 'debate', 'thenandnow']
myset = set(mylist)
print(myset)

If you use it further as a list, you should convert it back to a list…

Top comments (0)