Given
mylist = ['nowplaying', 'PBS', 'PBS', 'nowplaying', 'job', 'debate', 'thenandnow']
get the list of unique items. The output can be one of three ways:
['thenandnow', 'debate', 'nowplaying', 'PBS', 'job']
['nowplaying', 'PBS', 'job', 'debate', 'thenandnow']
['PBS', 'nowplaying', 'job', 'debate', 'thenandnow']
Performing list(d) on a dictionary returns a list of all the keys used in the dictionary, in insertion order
uniq_no_order = list(set(mylist)) print(uniq_no_order)
['nowplaying', 'job', 'debate', 'PBS', 'thenandnow']
uniq_first = list({key:1 for key in mylist}.keys()) print(uniq_first)
['nowplaying', 'PBS', 'job', 'debate', 'thenandnow']
uniq_last = list({key:1 for key in mylist[::-1]}.keys())[::-1] print(uniq_last)
['PBS', 'nowplaying', 'job', 'debate', 'thenandnow']