+ 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?

18th Feb 2018, 11:41 PM
Mdevlin0
5 odpowiedzi
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?
22nd Feb 2018, 11:03 PM
Mdevlin0
0
of course
23rd Feb 2018, 11:12 AM
Nomeh Uchenna Gabriel
Nomeh Uchenna Gabriel - avatar
0
assign it to a variable and access with the target key eg: https://code.sololearn.com/c8VA9EcmGe2R/?ref=app
24th Feb 2018, 10:33 PM
Nomeh Uchenna Gabriel
Nomeh Uchenna Gabriel - avatar
- 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))
19th Feb 2018, 12:35 AM
Nomeh Uchenna Gabriel
Nomeh Uchenna Gabriel - avatar
- 2
How?
24th Feb 2018, 9:37 PM
Mdevlin0