sir i want this out put how can add dynamically in dictionary not using as a 0,1,2,3,4,5 but use of j and j will be increment by 1 but when i use j but j=0 so only 1st will print not all so only one 1st print not increment so it gives only one row
RAM Processor LED HDD Price waranty
2GB core2due 9inch 150GB 30000 6month
4GB i3 10inch 200GB 40000 1year
8GB i2 12inch 300GB 50000 2year
16GB dualcore 14inch 500GB 60000 3year
1TB i5 15inch 1TB 35000 4year
2TB i7 16inch 2TB 29000 5year
parts=['RAM','Processor','LED','HDD','Price','waranty']
processor=['core2due','i3','i2','dualcore','i5','i7']
ram=['2GB','4GB','8GB','16GB','1TB','2TB']
price=[30000,40000,50000,60000,35000,29000]
hdd=['150GB','200GB','300GB','500GB','1TB','2TB']
waranty=['6month','1year','2year','3year','4year','5year']
led=['9inch','10inch','12inch','14inch','15inch','16inch']
j=0
dic1={}
dic2={}
dic3={}
dic4={}
dic5={}
dic6={}
shopcomputer={}
for i in parts:
for j in range(0,len(ram)):
if i=='RAM':
dic1[i]=ram[0] #but add dynamically means not using 0 using j
dic2[i]=ram[1]
dic3[i]=ram[2]
dic4[i]=ram[3]
dic5[i]=ram[4]
dic6[i]=ram[5]
if i=='Processor':
dic1[i]=processor[0]
dic2[i]=processor[1]
dic3[i]=processor[2]
dic4[i]=processor[3]
dic5[i]=processor[4]
dic6[i]=processor[5]
if i=='LED':
dic1[i]=led[0]
dic2[i]=led[1]
dic3[i]=led[2]
dic4[i]=led[3]
dic5[i]=led[4]
dic6[i]=led[5]
if i=='HDD':
dic1[i]=hdd[0]
dic2[i]=hdd[1]
dic3[i]=hdd[2]
dic4[i]=hdd[3]
dic5[i]=hdd[4]
dic6[i]=hdd[5]
if i=='Price':
dic1[i]=price[0]
dic2[i]=price[1]
dic3[i]=price[2]
dic4[i]=price[3]
dic5[i]=price[4]
dic6[i]=price[5]
if i=='waranty':
dic1[i]=waranty[0]
dic2[i]=waranty[1]
dic3[i]=waranty[2]
dic4[i]=waranty[3]
dic5[i]=waranty[4]
dic6[i]=waranty[5]
print dic1
print dic2
print dic3
print dic4
print dic5
print dic6
shopcomputer={}
shopcomputer[1]=dic1
shopcomputer[2]=dic2
shopcomputer[3]=dic3
shopcomputer[4]=dic4
shopcomputer[5]=dic5
shopcomputer[6]=dic6
print shopcomputer '\n'
for i in parts:
print '\t',i.rjust(2,),
print '\n',
for no1 in shopcomputer:
for no2 in shopcomputer[no1]:
print '\t',shopcomputer[no1][no2],
print '\n',
Aucun commentaire:
Enregistrer un commentaire