我正在尝试使用while循环将对象添加到列表中.
这基本上就是我想做的事情:
class x:
pass
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))))
Run Code Online (Sandbox Code Playgroud)
我可以将对象添加到列表中,但我仍然坚持如何在循环中向列表中添加多个对象.
这是我到目前为止的代码:
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 (choice==1):
print("STUDENT")
namer …Run Code Online (Sandbox Code Playgroud)