Answer the question
In order to leave comments, you need to log in
Why doesn't it exist in the attribute call?
class Client:
def __init__(self, client_id, name, phone, location, time):
self.client_id = client_id
self.name = name
self.phone = phone
self.location = location
self.time = time
AttributeError: type object 'Client' has no attribute 'client_id'
Answer the question
In order to leave comments, you need to log in
It looks like you are trying to get an attribute not of an object, but of a class. First create an object of the Client class, the __init__ constructor will run, which will create the required attribute on the new object:
class Client:
def __init__(self, client_id, name, phone, location, time):
self.client_id = client_id
self.name = name
self.phone = phone
self.location = location
self.time = time
my_client = Client(123456, "Vasya", "123456", "Lviv", 1234567890)
print(my_client.client_id)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question