Counting duplicates of random from my list
im trying to figure out how to count duplicates from the output of this code. Is there any way how to do it one code or do i have to make another to get the expected outcome?
Code:
import random
list = ['Bread','Money','Spoon','Beans','Caprisun!','Apple','Banana','Coffee','Doritos','Hotdog','Ice Cream']
for x in range(0,5):
prize = random.choice(list)
print (prize)
Output i get:
Bread
Bread
Money
Money
Money
Output i want:
2x Bread
3x Money
I never coded before and only made this work from tutorials I saw 20 minutes ago, so I dont even know if Im asking the right questions. Thanks for all the help in advance.
from Recent Questions - Stack Overflow https://ift.tt/38DDjLh
https://ift.tt/eA8V8J
Comments
Post a Comment