What do you want to save?
Add Code snippet
New code examples
-
Python 2021-10-02 01:33:02
import counter python
>>> from collections import Counter >>> >>> myList = [1,1,2,3,4,5,3,2,3,4,2,1,2,3] >>> print Counter(myList) Counter({2: 4, 3: 4, 1: 3, 4: 2, 5: 1}) >>> >>> print Counter(myList).items() [(1, 3), (2, ... Add solution -
Python 2021-09-27 21:06:06
find the highest 3 values in a dictionary.
from collections import Counter # Initial Dictionary my_dict = {'t': 3, 'u': 4, 't': 6, 'o': 5, 'r': 21} k = Counter(my_dict) # Finding 3 highest values high = k.most_common(3) print("Dictionary with 3 highest values:") print("Keys: Values&... Add solution -
Python 2021-09-22 22:14:03
counter in python
>>> from collections import Counter >>> >>> myList = [1,1,2,3,4,5,3,2,3,4,2,1,2,3] >>> print Counter(myList) Counter({2: 4, 3: 4, 1: 3, 4: 2, 5: 1}) >>> >>> print Counter(myList).items() [(1, 3), (2, ... Add solution -
Other 2021-09-21 06:44:02
counter in python
>>> from collections import Counter >>> >>> myList = [1,1,2,3,4,5,3,2,3,4,2,1,2,3] >>> print Counter(myList) Counter({2: 4, 3: 4, 1: 3, 4: 2, 5: 1}) >>> >>> print Counter(myList).items() [(1, 3), (2, ... Add solution -
Python 2021-09-18 15:31:02
count repeat values in python list
MyList = ["a", "b", "a", "c", "c", "a", "c"] return my_dict = {i:MyList.count(i) for i in MyList} # returns : {'a': 3, 'c': 3, 'b': 1} # OR from collections import Counter return my_d... Add solution -
Python 2021-09-14 00:09:01
count similar values in list python
MyList = ["a", "b", "a", "c", "c", "a", "c"] return my_dict = {i:MyList.count(i) for i in MyList} # returns : {'a': 3, 'c': 3, 'b': 1} # OR from collections import Counter return my_d... Add solution -
Python 2021-09-04 01:34:03
count values in list usiing counter
from collections import Counter Add solution