Home Get unique values from a list in python
Reply: 0

Get unique values from a list in python

user495
1#
user495 Published in June 20, 2018, 7:17 am

I want to get the unique values from the following list:

[u'nowplaying', u'PBS', u'PBS', u'nowplaying', u'job', u'debate', u'thenandnow']

The output which I require is:

[u'nowplaying', u'PBS', u'job', u'debate', u'thenandnow']

This code works:

output = []
for x in trends:
    if x not in output:
        output.append(x)
print output

is there a better solution I should use?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.510608 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO