Skip to content

Commit f65a064

Browse files
committed
dictionary exercises complete
1 parent bd727b5 commit f65a064

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

038_dict_operations.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,16 @@
6767
# Since there are two words of length 3, etc.
6868

6969
def count_words_by_length(words):
70-
pass
70+
word_length_counts = {}
71+
for word in words:
72+
length = len(word)
73+
74+
if length not in word_length_counts:
75+
word_length_counts[length] = 1
76+
else:
77+
word_length_counts[length] += 1
78+
79+
return word_length_counts
7180

7281
check_that_these_are_equal(
7382
count_words_by_length(["hat", "cat", "I", "bird"]),

0 commit comments

Comments
 (0)