Sep-11-2022, 03:27 PM
(This post was last modified: Sep-11-2022, 03:29 PM by python202209.)
I save a txt file with name 1pytest.txt and python the codes as a python file with name 1py.py in the same folder c:\Users\tiger\Downloads\
see screenshot (files in folder) in attachment
Can anyone tell me how to solve the problem? Thanks
name = input('Enter file:') handle = open(name, 'r') counts = dict() for line in handle: words = line.split() for word in words: counts[word] = counts.get(word, 0) + 1 bigcount = None bigword = None for word, count in list(counts.items()): if bigcount is None or count > bigcount: bigword = word bigcount = count print(bigword, bigcount)see screenshot (error message) in attachment
see screenshot (files in folder) in attachment
Can anyone tell me how to solve the problem? Thanks