Skip to content

Instantly share code, notes, and snippets.

@Hossara
Created January 4, 2023 10:38
Show Gist options
  • Save Hossara/d61b53a7a62f6389f7e3503890d22328 to your computer and use it in GitHub Desktop.
Save Hossara/d61b53a7a62f6389f7e3503890d22328 to your computer and use it in GitHub Desktop.
Program that get size and get list of space separated items and returns count of each items of list.
def solve(list, size):
list = list.split(" ")
count_list = [None] * size
index = 0
for i in list:
count = 0
for j in list:
if i == j:
count += 1
count_list[index] = str(count)
index += 1
return ' '.join(count_list)
n = int(input())
list = input()
while len(list.split(" ")) != n: list = input()
print(solve(list, n))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment