I have following list:
files_list = ['pic1.jpg', 'pic2.jpg', 'pic3.jpg', 'movie1.mov', 'movie2.mov', 'doc1.pdf', 'doc2.pdf', 'doc3.pdf', 'doc4.pdf']
I want to count the number of items with a particular file extension and store it in a dictionary.
Expected output is:
extn_dict = {'jpg': 3, 'mov': 2, 'pdf': 4}
I'm writing following code:
for item in files_list:
extn_dict[item[-3:]] = count(item) # I understand I should not have count() here but I'm not sure how to count them.
How can I count the number of items in the list with a particular extension?