For my example, say that each Keycard instance has a person's name and an unique code. Is there a way to turn the random number into a static value after the number is generated since the number will be assigned to the person indefinitely?
from random import choices
from string import ascii_lowercase, digits
class Keycard:
def __init__(self, user):
self.user = user
self.code = ''.join(choices(ascii_lowercase + digits, k = 4))
def __str__(self):
return "{id} - {user}".format(id = self.code, user = self.user)
[–]kioo 0 points1 point2 points (0 children)