You keep counts in an integer count
variable. Change to a list/dict representing the count of each side of the dice.
list:
import random
counts = [0] * 6
for i in range(10):
roll = random.randint(1,6)
print("roll number" , i, ":" , roll)
counts[roll-1] += 1
for side, count in enumerate(counts):
print(side+1, "was rolled", count, "amount of times")
dict:
import random
from collections import defaultdict
counts = defaultdict(int)
for i in range(10):
roll = random.randint(1,6)
print("roll number", i+1, ":", roll)
counts[roll] += 1
for side, count in counts.items():
print(side, "was rolled", count, "amount of times")
* this will print the counts in order of the first appearance of each side
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…