Python 1. I have to write a function based on a open file that has one lowercase word per line. I have to return a dictionary with keys in single lowercase letters and each value is a list of the words from the file that starts with that letter. (the keys in the dictionary are from only the letters of the words that appear in the file) Can someone help me create the above function? Thanks!
2. In the provided dictionary, all keys consist of a single lowercase letter and each value is a list of lowercase words starting with the letter. Return a new dictionary with each key a single lowercase letter and each value the number of lowercase words that start with that letter. I don't get this one too. Like I don't know how to incorporate the for/while loops and/or is statements...
The Python docs give good examples/explanations of what you need to do these problems. The for loop was the funkiest part, and that just Pythonic: for theWord in the File: These problems are basically identical. The functions, with error checking, are about 11 lines of code. We're not supposed to give people the code for their assignments, so last night's and tonight's answers are the best I'm allowed to do.
Oh alright. Thanks!
Join our real-time social learning platform and learn together with your friends!