Created
September 29, 2019 15:56
-
-
Save begimai/41e7f756042b007a7acd15ed39513ce6 to your computer and use it in GitHub Desktop.
You are given words. Some words may repeat. For each word, output its number of occurrences. The output order should correspond with the input order of appearance of the word. See the sample input/output for clarification.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my_dict = {} | |
num = int(input()) | |
for x in range(num): | |
word = input() | |
if word in my_dict: | |
my_dict[word] += 1 | |
else: | |
my_dict[word] = 1 | |
print(len(my_dict)) | |
for x, y in my_dict.items(): | |
print(y, end=' ') | |
print() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment