Most efficient way to store dice rolls? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Most efficient way to store dice rolls?

roll_d6 = random.randint(1,6) What is the most efficient way to store the result of each roll for x amount of rolls? Thanks!

11th Mar 2017, 3:30 AM
Josh Redinger
2 Answers
+ 7
import random dice = [] for throws in range(10): dice += [random.randint(1,6)] print(dice)
11th Mar 2017, 6:12 AM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 4
You could store it in an array, so something like this: rolls = [0, 0, 0, 0, 0, 0] roll_d6 = random.randint(1, 6) rolls[roll_d6]++
11th Mar 2017, 6:09 AM
Keto Z
Keto Z - avatar