Question: This is from a midterm example question. Can someone help me code this? code a function called readFile(filename) which takes as an argument the name

This is from a midterm example question. Can someone help me code this?

code a function called readFile(filename) which takes as an argument the name of a text file, opens and reads the file containing words, and returns a dictionary containing the number of words in the file that have length 1, 2, 3, etc ... up to the longest word in the file. Ignore any word that is not all letters. This method should not interact with the user (10 pts) Parameter: filename is a string representing the name of the input text file. Return: dictionary ex: If the text file has "to be or not to be" then the dictionary should have { 2:5, 3:1 }.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!