class A:
id = ""
fld = []
def __init__(self, id):
self.id = id
def method(inp):
a = A("a")
b = A("b")
c = A("c")
a.fld.append("Histogram")
a.fld.append("Dendogram")
b.fld.append("Milligram")
b.fld.append("Pictogram")
c.fld.append("Pro--gram")
c.fld.append("Dodge-ram")
print a.fld
print b.fld
print c.fld
inp.append(a)
inp.append(c)
inp.append(b)
#__main__
inp = []
method(inp)
for ins in inp:
print "-----> " + ins.id
for fl in ins.fld:
print fl
Trying to understand why 18.print prints all the 12_17.appends
I am completely new and practising. Pls help!
['Histogram', 'Dendogram', 'Milligram', 'Pictogram', 'Pro--gram', 'Dodge-ram']
['Histogram', 'Dendogram', 'Milligram', 'Pictogram', 'Pro--gram', 'Dodge-ram']
['Histogram', 'Dendogram', 'Milligram', 'Pictogram', 'Pro--gram', 'Dodge-ram']
-----> a
Histogram
Dendogram
Milligram
Pictogram
Pro--gram
Dodge-ram
-----> c
Histogram
Dendogram
Milligram
Pictogram
Pro--gram
Dodge-ram
-----> b
Histogram
Dendogram
Milligram
Pictogram
Pro--gram
Dodge-ram