Answer to Question #350141 in Python for Laiba

Question #350141

Write a program that reads some integers between 1 to 100 and counts the occurance of each.




1
Expert's answer
2022-06-13T08:26:32-0400
nums_count = {}
inp = input()
while inp:
    num = int(inp)
    if num in nums_count:
        nums_count[num] += 1
    else:
        nums_count[num] = 1
    inp = input()
for num, occurance in nums_count.items():
    print(f'{num}: {occurance}')

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS