I have a dict of lists in python:
content = {88962: [80, 130], 87484: [64], 53662: [58,80]}
I want to turn it into a list of the unique val
use set()
and itertools.chain()
:
In [83]: content = {88962: [80, 130], 87484: [64], 53662: [58,80]}
In [84]: from itertools import chain
In [94]: x=set(chain(*content.values()))
In [95]: x
Out[95]: set([58, 64, 80, 130]) # a set, the items may or may not be sorted
In [96]: sorted(x) #convert set to a sorted list
Out[96]: [58, 64, 80, 130]