The class definition:
class tr():
def __init__(self,l=[]):
self.l = l
def added(self):
self.l.append(1)
colt1 = tr()
colt1.added()
print(colt1.l)
Output is [1] Executed the below code after the above one
colt2 = tr()
colt2.added()
print(colt2.l)
Output is [1, 1]
I would like to have the output for the second segment also to be [1] with the class getting the data members from the init function and also having a default argument. So how should I alter the code to get this output?