collections - how to counter Multiply times python -
im new python , have questions want ask
the question how counter multiply times
there 6 dice stand
import random collections import counter amt = 1 point = 0 dicestand = 6 dice1 = random.randint(1,6) dice2 = random.randint(1,6) dice3 = random.randint(1,6) dice4 = random.randint(1,6) dice5 = random.randint(1,6) dice6 = random.randint(1,6) roll = [dice1,dice2,dice3,dice4,dice5,dice6] print("do want play dice game?") print("turn " , amt , " of 3") print("you have", point,'point') print("you roll") k in range(1): print(roll) counts = counter(roll) print (counter(counts)) result :
[4, 1, 5, 6, 1, 4] counter({4: 2, 1: 2, 5: 1, 6*1}) how can print message , counter multiply times 4*3 = 12 , 1*2 = 2 more 2 times multiply
then there 4 dice used
but can roll remaining dice 2 dices 1 time 12 , 2 save point after 3 attempt end of game
really want understand how use random value , counter thank
if i'm understanding correctly, want print product of repeat dice rolls, e.g. if roll '2' 4 times, print "2 * 4 = 8"
if that's case, work:
import random amt = 1 point = 0 dicestand = 6 dice1 = random.randint(1,6) dice2 = random.randint(1,6) dice3 = random.randint(1,6) dice4 = random.randint(1,6) dice5 = random.randint(1,6) dice6 = random.randint(1,6) roll = [dice1,dice2,dice3,dice4,dice5,dice6] print("do want play dice game?") print("turn " , amt , " of 3") print("you have", point,'point') print("you roll") in range(1,7): total = 0 die in roll: if == die: total += 1 print i, " * ", total, " = ", i*total edit: here example output
do want play dice game? ('turn ', 1, ' of 3') ('you have', 0, 'point') roll 1 * 1 = 1 2 * 0 = 0 3 * 2 = 6 4 * 2 = 8 5 * 1 = 5 6 * 0 = 0
Comments
Post a Comment