-
Notifications
You must be signed in to change notification settings - Fork 0
4a #6
Copy link
Copy link
Open
Description
file=open("testsimple.txt","r")
text=file.read().lower()
words=text.split()
freq={}
for w in words:
if w in freq:
freq[w] += 1
else:
freq[w] = 1
sorted_words=sorted(freq.items(),key=lambda x:x[1],reverse=True)
print("Top frequent words:")
for i in range(min(10,len(sorted_words))):
print(sorted_words[i])
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels