0
Is count and counter are same?
3 Respostas
+ 1
A "Counter" is a container from python module collections, that keeps track of how many times equivalent values are added.
Sample code:
import collections
cnt = collections.Counter()
cnt.update('abcdaab') # adding a string
cnt.update({'a':1, 'd':5}) # adding a dict
print('Counter :', cnt)
#result: Counter({'d': 6, 'a': 4, 'b': 2, 'c': 1})
0
It will be better give a sample, Where about you taking in the code..!
In python, List has a predefined count function, but I think there is no predefined function like counter in python.. It is user defined as far i know.... It may be from other modules...
Edit: ex:
L=[1,2,1,1,3 ]
print(L.count(1)) #prints 3, =>1's count in list...
- 1
yes🤷♀️😂