In python2.7, the following code takes the dictionary fd
(in this example representing a frequency distribution of words and their counts), and separates it into a list of two lists: [[the keys],[values]]:
sortedDKandVs = [zip(*sorted(fd.items(), key=itemgetter(1), reverse=True))] #[word,word,...],[count,count]
I can then do, for example:
keys = sortedDKandVs[0]
values = sortedDKandVs[1]
This no longer works in Python3 and I want to know how to transform the code.
None of the answers here How to unzip a list of tuples into individual lists? work anymore because in Python3 zip objects return iterators instead of lists, but I am not sure how to transform the answers.