Skip to content

Commit 84d9cbe

Browse files
committed
last part
1 parent 97bb002 commit 84d9cbe

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

Dictionary/main10.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# python words.py
2+
# Enter file: words.txt
3+
# to 16
4+
5+
6+
7+
name = input('Enter file: ')
8+
handle = open(name)
9+
10+
counts = dict()
11+
12+
13+
counts = dict()
14+
for line in handle:
15+
words = line.split()
16+
for word in words:
17+
counts[word] = counts.get(word, 0) + 1

Dictionary/main11.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# python words.py
2+
# Enter file: clown.txt
3+
# the 17
4+
5+
6+
bigcount = None
7+
bigword = None
8+
9+
for word,count in counts.items():
10+
if bigcount is None or count > bigcount:
11+
bigword = word
12+
bigcount = count
13+
print(bigword, bigcount)

0 commit comments

Comments
 (0)