nop = 0
patron = list
def createnew(firstname, lastname, phone, age, gender):
name = (lastname.lower() + ", " + firstname.lower())
patron.append(patrons(name, phone, age, gender))
nop += 1
class patrons():
number = 1
def __init__(self, name, phone, age, gender):
self.name = name
self.phone = phone
self.age = age
self.gender = gender
There's a couple of parts of my code for a program that holds information about library patrons. What I want to do is store all the members of the class (patrons) in a list (patron), I know the names are a little confusing, I wasn't really thinking, sorry about that. The problem which I am encountering is that when I run the createnew function, I receive an error which says "descriptor 'append' requires a 'list' object but received a 'patrons'" I was under the impression that I could store class objects in a list. Am I unable to do this? If I can do it, what do I have to change?