Question: Write a Python function count _ letters ( file ) for counting letters in a text file. Input: name of file relative to the present
Write a Python function countlettersfile for counting letters in a text file.
Input: name of file relative to the present working directory pwd see below eg countlettersfrosttxt if 'frost.txt is in the pwd
Output: return the dictionary of letter:count pairs. Only include letters present in the file.
Use a dictionary to hold a mapping between a letter and its number of occurrences.
Ignore characters and symbols that are not standard ascii characters only use characters that appear in string.asciilowercase
Ignore case; eg consider 'Treat' as having ts instead of T and t
Reading files You can use open to open a file. It creates an iterator that goes through the file, line by line.
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
