[Tutor] creat a program that reads frequency of words in file :p:

Thomas C. Hicks paradox at pobox.com
Mon Jun 1 23:35:10 CEST 2015


On 06/01/2015 05:56 PM, Alan Gauld wrote:
>> if text in line:
>>              count += 1
>>      print("This word appears", count, "times in the file")
>
> And this is, of course, completely off track. You need
> to split the line into its separate words and store
> each word into the dictionary. 
OP may want to research the setdefault and get methods for dictionaries.

SDG,

tom


More information about the Tutor mailing list