(no subject)

Nov 10, 2013 18:30


# -*- coding:utf8 -*-
class GetResult:
result=[]
def add(self,x,y):
z= x+y
self.result.append(z)

rs=GetResult()
rs.add(1,2) #the result is [3]
print rs.result
rs.add(3,4)#the result is [7] #what i want the is [4]
print rs.result
Previous post Next post
Up