I started out by using a For loop to send each word from a single line to the dictionary mapping function. Once this was working and proved that the dictionary mapping function worked, I re-factored the code to use the map() function instead of the For loop. Perhaps I could save some time in the mapping function (named wordcounter) by using the .setdefault method of the Dictionary object instead of explicitly checking for a key's existence in the Dictionary every time the function is called.
Reading materials:
http://docs.python.org/library/stdtypes.html#dict
http://docs.python.org/library/stdtypes.html#dict
No comments:
Post a Comment