Ask your own question, for FREE!
Computer Science 18 Online
OpenStudy (he66666):

Python: dictionary question? 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 please help me create the function for this?

OpenStudy (rsmith6559):

In a framework way: read a line from the file if the dictionary has the key line[0] append the line to the list else create the key/value return the dictionary

OpenStudy (he66666):

I still don't know what to do.. I don't under how to code "if the dictionary has the key line[0]" and "create the key/value"...

OpenStudy (he66666):

understand*

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!