Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to count the repeatance of every string in a list python

MyList = ["b", "a", "a", "c", "b", "a", "c", 'a']
res = {}

for i in MyList:
    res[i] = MyList.count(i)
    
print(res)

# the output will be a dict
#{'b': 2, 'a': 4, 'c': 2}
Comment

PREVIOUS NEXT
Code Example
Python :: change python version jupyter notebook 
Python :: how to count discord chat messages with python 
Python :: website screenshot python compress image 
Python :: Understand the most appropriate graph to use for your dataset 
Python :: ansible custom module 
Python :: printing range of index in python 
Python :: read sharepoint list using python 
Python :: turtle screen close error fix 
Python :: how to add other categories in django admin template 
Python :: map column dataframe python 
Python :: Move x-ticks to the middle of each bin 
Python :: how to change graph after every second in python 
Python :: replace python enter number of characters 
Python :: python kdtree import 
Python :: pandas set index integer not float 
Python :: odoo 12 compute documentation 
Python :: WAP which defines and calls a function that receives an octal number and prints the equivalent number bases i.e. in decimal, binary and hexadecimal equivalents. 
Python :: iptc text classification example 
Python :: python change type of every element in a dictionary 
Python :: how to check what version of pygame you have instaled 
Python :: docstrinfs pyt 
Python :: python check mognodb size 
Python :: numpy slice double colon stack overflow 
Python :: sowpods python 
Python :: Filters rows using the given condition 
Python :: python triée plusieurs fois avec virgule 
Python :: slicing time series 
Python :: write python command to display your name 
Python :: python set class variable 
Python :: how to subtract numbers in python 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =