I have the following code:
class Cola:
def __init__(self):
self.cola = []
def add_list(self, element):
self.cola.append(element)
def numElements(self):
return len(self.cola)
def list_entry():
membership= input(" Membership card? (y/n): ")
name= input(" Name: ")
lastname= (input(" Lastname: "))
return (membership, name, lastname)
def add_list():
new= list_entry()
Cola().add_list(new)
n = int(input("Choose an option\n 1.Add to waiting list\n 2.Show waiting customers\n 3.Close for today\n Option: "))
while n<5:
if n==1:
add_list()
n = int(input("Choose an option\n 1.Add to waiting list\n 2.Show waiting customers\n 4.Close for today\n Option: "))
elif n==2:
waiting= Cola().numElements()
print(waiting)
n = int(input("Choose an option\n 1.Add to waiting list\n 2.Show waiting customers\n 4.Close for today\n Option: "))
elif n==3:
print("See you")
n=5
The problem is that I expect that when user choose 3, the number of instance in the list should appear but instead I always get 0, which tells me that I´m not really adding anything to the list What am I doing wrong?
Extra: I suspect that for on the long run a list of lists will be more useful How can I do that?