I wanted this dice program to simulate the roll of a six sided die everytime I roll the six sided die ten times using a forloop.
As I stated, I wrote a for loop and specified the number of times I wanted the six sided die to roll.
import random class Die(): def __init__(self): self.sides=6 def roll_die(self): dice=random.randint(1,self.sides) for dice in range(11): print("Rolling "+str(dice)) dice_roll=Die() print("=========================================================") dice_roll.roll_die()
========================================================= Rolling 0 Rolling 1 Rolling 2 Rolling 3 Rolling 4 Rolling 5 Rolling 6 Rolling 7 Rolling 8 Rolling 9 Rolling 10
I expected the for loop in my simulation to print a bunch of random numbers that range from 1 to 6 ten times. Instead, it printed the numbers in order and did not only print numbers that ranged from 1 to 6.