When naming an oject with user defined attributes it says the name of object (NameError) is not used ..
Here is the part that creates an object with user defined attributes from a class called 'Dog':
def menu():
print('1. Register a new dog')
print('2. Ammend dog deatils')
print('3. Remove dog')
choice = int(input('>> '))
if choice == 1:
Name = input('Name >> ').title()
Age = int(input('Age >> '))
Breed = input('Breed >> ').title()
Energy = int(input('Energy >> '))
Hunger = int(input('Hunger >> '))
dog2 = Dog(Name, Age, Breed, Energy, Hunger) <--- ***HERE IS THE PROBLEM***
Error Message:
Traceback (most recent call last):
File "<input>", line 1, in <module>
NameError: name 'd2' is not defined
Line 1 of my code is just the class definition :
class Dog:
def __init__(self, n, a, b, e, h):
self.name = n.title()
self.age = a
self.breed = b.title()
self.energy = e
self.hunger = h
Relativley new to OOP so any help is much appreciated.
PS. I want to create an object but with a user defined name eg:
#user defined name = Dog(XXX,YYY)