Read a file into a dictionary where the key is the word and

#Read a file into a dictionary, where the key is the word and the value is the number of words

def read_dictionary(fileName):
  

Solution

def read_dictionary(fileName):

f = open(fileName,\"r\");
lines = f.readlines();

words=[]
for i in lines:
thisline = i.split(\" \");

words=words+thisline

dict={}

for i in range(0,len(words)):

count=0

for j in range(i,len(words)):

if words[i]==words[j]:

count=count+1

words[j]=None

dict[words[i]]=count

#Read a file into a dictionary, where the key is the word and the value is the number of words def read_dictionary(fileName): Solutiondef read_dictionary(fileNa

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site