I made a class which looks like this:
import numpy.random as rand
class Dice:
def __init__(self):
self.x=0
def roll(self):
self.x=int(rand.randint(1,7,1))
print(self.x)
Now, I want to roll two dices and make an array with the results.
A=Dice()
B=Dice()
aaa=[A.x, B.x]
print(aaa)
A.roll()
B.roll()
print(aaa)
The results look like:
[0, 0]
2
4
[0, 0]
What I wanted this code to act is to make the array update itself whenever the number inside changes. I know that I can make this with making another function, but is there any other ways to make this work more elegantly?