my_list=raw_input('Please enter a list of items (seperated by comma): ')
my_list=my_list.split()
my_list.sort()
print "List statistics: "
print ""
for x in set(my_list):
z=my_list.count(x)
if z>1:
print x, "is repeated", z, "times."
else:
print x, "is repeated", z, "time."
The output only prints one of the items in the list. I need to sort the list (dog, cat, bird, dog, dog) to count how many items are in the list, such as:
bird is repeated 1 time. cat is repeated 1 time. dog is repeated 3 times.
The problem is that it only outputs 1 item:
bird is repeated 1 time.