Dec-02-2018, 06:21 PM
The second code sets up a dictionary of the sides of the die and the counts:
You can do this with a list as well as a dictionary.
{1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0}
. So ROLLED[5] is the number of times a five has been rolled. The loop on line 13 rolls the die ITERATIONS times (however many times you want it to) and records the results of each roll. The probability function just prints the results.You can do this with a list as well as a dictionary.
ROLLED = [0] * 7
would work just as well, although you would have to rewrite the probability function.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures