I'm new to Python and I'm stuck trying to figure out how to count how many times a number shows up in a list. The output I'm looking for is something like this "7 occurred 2 times, 4 occurred 1 time" but the problem I'm running into is that I'm printing output for each my_integer. So if I enter 7, 7, 4 as input I get "7 occurred 2 times, 7 occurred 2 times, 4 occurred 1 time" I was thinking of writing a method to check for uniqueness of a number after count has been returned.
integers = input("Enter integers between 1 and 100: ")
split_integers = integers.split()
integer_list = [eval(x) for x in split_integers]
for my_integer in integer_list:
print(integer_list.count(my_integer))