r/codeHS_Solutions • u/Nexus_X__ • Feb 13 '22
9.5.7 Word Counts, Part 2
text = input("Enter some text: ")
text_list = text.split()
dic = {}
def update_counts(count_dictionary, word):
if word in count_dictionary:
count_dictionary[word] = count_dictionary[word] + 1
else:
count_dictionary[word] = 1
for word in text_list:
update_counts(dic, word)
print(dic)
6
Upvotes
1
u/Jongames0 Jun 13 '22
text = input("Enter some text: ")
text_list = text.split()
dic = {}
def update_counts(count_dictionary, word):
if word in count_dictionary:
count_dictionary[word] = count_dictionary[word] + 1
else:
count_dictionary[word] = 1
for word in text_list:
update_counts(dic, word)
print(dic)
This is the correct indention just incase
1
u/Creative_Tree_6113 Apr 20 '23
Correct indents 000(enter/ or space)01212010
1
u/Lillazy06_Yeah_Yeah May 09 '23
.