+ 2
Lists from lists
In python 3, is there a way to take a large list of numbers, and then create a new list based on the frequency of each number from greatest to least?
5 Respostas
0
This is great! This is easier than what I was trying to do for the first part. But is there a way to use the dictionary outputs as new retrievable inputs based on their count value?
0
of course
0
assign it to a variable and access with the target key
eg: https://code.sololearn.com/c8VA9EcmGe2R/?ref=app
- 1
Counter can take a list and return the frequency of each element as a dictionary
EG...
from collections import Counter as ctr
list = [2, 3, 5, 6, 2, "g", 2, 5, "g"]
print(ctr(list))
- 2
How?