mercredi 9 novembre 2022

Random number in class repeating when printed multiple times [BEGINNER QUESTION]

`

class multiplication1d2d:
    num1 = random.randint(1, 20)
    num2 = random.randint(1, 20)
    q = f'{num1} x {num2}'
    ans = num1 * num2

`

When I print the classes num1 and num2 aspects, they repeat. How do I fix this?

print (numltiplication1d2d.num1) print (numltiplication1d2d.num1) print (numltiplication1d2d.num1)




Aucun commentaire:

Enregistrer un commentaire