This might be very bad example, but I'm new with OOP, I'm trying to get the same self.number list that I have created inside random_number without calling random.randint again. but self.number is empty when I'm calling inside class B, what can be the right approach?
import random
class A:
def __init__(self):
self.number = []
def random_number(self):
for i in range(4):
self.number.append(random.randint(1, 100))
random.randint(1, 100)
print("from class A", self.number)
class B(A):
def __init__(self):
super().__init__()
# something here
def get_name(self):
A().random_number()
print("from class B", self.number)
B().get_name()