This is from the grok learning website for favorite dessert. I am not sure how to get it to add how many of the votes occured.
votes = {}
msg = input("Name:vote ")
while msg:
name, vote = msg.split(":")
if vote not in votes:
votes[vote] = [name]
else:
votes[vote].append(name)
msg = input("Name:vote ")
for vote in votes:
print(vote, vote.count(votes), "vote(s):", ' '.join(votes[vote]))
This is the expected outcome:
Name:vote Greg:chocolate
Name:vote Teena:macaroons
Name:vote Georgina:apple pie
Name:vote Will:chocolate
Name:vote Sophia:gelato
Name:vote Sam:ice cream
Name:vote James:chocolate
Name:vote Kirsten:gelato
Name:vote
apple pie 1 vote(s): Georgina
gelato 2 vote(s): Sophia Kirsten
chocolate 3 vote(s): Greg Will James
macaroons 1 vote(s): Teena
ice cream 1 vote(s): Sam