I have a simple class that stores information about people attending a conference:
class Attendee:
def __init__(self, fName, lName, email):
self.fName = fName
self.lName = lName
self.email = email
I am attempting to create Attendee objects using a combination of two user-inputed strings:
#get inputs from user:
fName = input("First name: ")
lName = input("Last name: ")
.....
newObjectName = fName[0] + lName
newObjectName = Attendee(fName, lName, email)
Obviously this will not work – but you get the idea I’m shooting for.
I know in C# you can create a new object by:
Attendee newObjectName = new Attendee(fName, lName, email)
How would this translate to Python?
Thanks
If you want to have variable variable names, then you want a different data structure instead. For example, a dictionary works well: