i have dict and list as bellow
a = {'aaa': 1, 'bbb': 2, 'ccc': 3}
b = ['aaa', 'bbb', 'ddd', 'eee']
I am comparing list b
in dict a
and I am printing values of 'aaa'
and 'bbb'
, I dont know how to store values of aaa=1
, bbb=2
. I am trying using this code
for i in range(0,len(b)):
if b[i] not in d:
continue
else:
print int(a[b[i]])
its printing
1
2
i want to assign aaa=1,bbb=2,ddd=0,eee=0
.
And Then when I print "print aaa,bbb,ccc,ddd"
it should print values. The variables in list b
can vary, so that I should dynamically assign values which are in b
not in a to zero.