Global variable does not update but I import it to interpreter it is updating.
Please help me how to update dictionary d
import texttable
class Lc:
d={50:8,100:6,200:4,500:3,1000:2,2000:1}
he=['container_size_in_ltrs','qty']
def inventory(self,g):
d1=self.d
if d1!=g:
d1=g
self.d=g
l1=d1.keys()
l1.sort()
li=[]
ls=[]
for i in l1:
li=[]
li.append(i)
li.append(d1[i])
ls.append(li)
table=texttable.Texttable()
table.header(self.he)
table.add_rows(ls,header=False)
print table.draw()
def add_inv(self,k,v):
d=self.d
for i,j in d.items():
if k==i:
d[k]=d[k]+v
print d
return d
z=Lc()
g=z.add_inv(500,2)
print z.d