Hey guys so im trying to use a while loop to add objects to a list.
Heres bascially what i want to do: (ill paste actually go after)
class x:
blah
blah
choice = raw_input(pick what you want to do)
while(choice!=0):
if(choice==1):
Enter in info for the class:
append object to list (A)
if(choice==2):
print out length of list(A)
if(choice==0):
break
((((other options))))
as im doing this i can get the object to get added to the list, but i am stuck as to how to add multiple objects to the list in the loop.
Here is my actual code i have so far...
print "Welcome to the Student Management Program"
class Student:
def init (self, name, age, gender, favclass):
self.name = name
self.age = age
self.gender = gender
self.fac = favclass
choice = int(raw_input("Make a Choice: " ))
while (choice !=0):
if (guess==1):
print("STUDENT")
namer = raw_input("Enter Name: ")
ager = raw_input("Enter Age: ")
sexer = raw_input("Enter Sex: ")
faver = raw_input("Enter Fav: ")
elif(guess==2):
print "TESTING LINE"
elif(guess==3):
print(len(a))
guess=int(raw_input("Make a Choice: "))
s = Student(namer, ager, sexer, faver)
a =[];
a.append(s)
raw_input("Press enter to exit")
any help would be greatly appreciated!