Question: Question 1 . 2 Write a function called count _ file _ types that takes as input a folder ( a Path object ) ,
Question
Write a function called countfiletypes that takes as input a folder a Path object and returns a dictionary with the number of files of each type in the folder. That is if the folder contains txt files and pdf files, then the returned dictionary will be
txt:pdf:
Hints:
Use for p in folder.iterdir to iterate through the items in the folder.
Use isfile to check that an item is a file and not a subdirectory
Get a file's extension with psuffix.
Check whether a string a is a key in a dictionary A with a in Akeys
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
