FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
PythonLearning/58.CounterCollectioninPython.py at Pythontuts · aditya0035/PythonLearning · GitHub
aditya0035
/
PythonLearning
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
PythonLearning
/
58.CounterCollectioninPython.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
37 lines (34 loc) · 1.25 KB
Breadcrumbs
PythonLearning
/
58.CounterCollectioninPython.py
Copy path
File metadata and controls
37 lines (34 loc) · 1.25 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""
Counter collection is present in collection module of python
it is not global module so we need to import it
Counter collection count the number of occurance of each element of the
collection and store them in dic form
Also we can use counter with other collection as well like
dict ,tuple , queue etc
"""
from
collections
import
Counter
lst
=
[
1
,
2
,
3
,
4
,
51
,
2
,
1
,
23
,
1
,
2
,
33
,
4
,
4
,
67
,
7
]
count
=
Counter
(
lst
)
print
(
count
)
"""
Counter collection is present in collection module of python
it is not global module so we need to import it
Counter collection count the number of occurance of each element of the
collection and store them in dic form
Also we can use counter with other collection as well like
dict ,tuple , queue etc
"""
from
collections
import
Counter
lst
=
[
1
,
2
,
3
,
4
,
51
,
2
,
1
,
23
,
1
,
2
,
33
,
4
,
4
,
67
,
7
]
count
=
Counter
(
lst
)
print
(
count
)
"""
Counter collection is present in collection module of python
it is not global module so we need to import it
Counter collection count the number of occurance of each element of the
collection and store them in dic form
Also we can use counter with other collection as well like
dict ,tuple , queue etc
"""
from
collections
import
Counter
lst
=
[
1
,
2
,
3
,
4
,
51
,
2
,
1
,
23
,
1
,
2
,
33
,
4
,
4
,
67
,
7
]
count
=
Counter
(
lst
)
print
(
count
)
Back
|
FazBrowse Home
|
New Git URL