why do I only end up with one object in the list
i want to keep appending
I am sure the answer is simple, thanks
studRoll = []
def GetInteger(i):
try:
return int(i)
except:
return 0
class stud:
def __init__(self, a, n, m):
self.age = a
self.name = n
self.mark = m
def ShowRoll():
for stud in studRoll:print "\n\n\n>>>> Student Roll List <<<";print (stud.age,"-",stud.name,"-",stud.mark)
def AppendStudent(age,name,mark):
global studRoll
a = int(age)
n = "" + name
m = int(mark)
s = stud(a,n,m)
print "B4"
ShowRoll()
studRoll.append(s)
s = None
print "after"
ShowRoll()
def AppendStudentObject(s):
global studRoll
studRoll.append(s)
print "****************** START OF RUN *******************"
ShowRoll()
AppendStudent (1,"A",2)
AppendStudent (2,"b",4)
AppendStudent (3,"c",6)
studage=50
studname="kathleen"
studmark=90
AppendStudent (studage,studname,studmark)
s1=stud(4,"44",4)
s2=stud(5,"55",5)
s3=stud(6,"66",6)
AppendStudentObject(s1)
AppendStudentObject(s2)
AppendStudentObject(s3)
ShowRoll()
Editor's note:
Please use the [code] and [/code] tag pair to enclose your code.