First of all I'd like to say im a Python beginner (or programming beginner for that matter) and I'm trying to figure out how to print attributes from a object based on user input.
This is the code I have so far:
class Customer:
"De klasse customer"
def __init__(self, naam, adres, woonplaats, email):
self.naam = naam
self.adres = adres
self.woonplaats = woonplaats
self.email = email
input1 = input ("Enter the object name")
print(input1.naam) ## ** << This is what i like to know**
a = Customer('Name1', 'address', 'Utrecht', '[email protected]')
b = Customer('Name2', 'Bonestaak', 'Maarssen', 'Bijjaapishetaltijdraakhotmail.com')
So I basically want this: print(a.naam) to work, but the 'a' must be entered by a user.
Did some searching but no success so far.
naamattribute), and variable names are supposed to be under your control. Think about it: if you leave it up to the user to name your variable, then how do you expect to know what name to use, so you can check what is in the variable and use it? You are writing the code before the user gives you a name...