Answer the question
In order to leave comments, you need to log in
How to create an object for a class through the def function?
def buyLada():
if car1.balance < 200:
print('У вас недостаточно средств')
else:
car1.balance -= 200
print(f'Вы приобрели Lada!!!!! Теперь ваш баланс {car1.balance}')
money = car1.balance
car2 = Car('Lada',180,120,0,120,120,money)
вот код, после успешного срабатывания метода и попытке вызвать информацию для car2 выводит ошибку
NameError: name 'car2' is not defined
Answer the question
In order to leave comments, you need to log in
The created instance of the class must be returned from the function using return. And assign the result of executing such a function to the variable you need.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question