Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MC={'рыба': ['100'], 'мясо': ['120']}
- RC={'рыба': ['3'], 'мясо': ['2']}
- CG={'рыба': ['300'], 'мясо': ['240']}
- CG = {}
- for key in MC.keys():
- try:
- CG[key] = [str(int(count) * int(RC[key][index])) for index, count in enumerate(MC[key])]
- except KeyError:
- CG[key] = MC[key]
- CG={}
- GC=[]
- FG=[]
- FM=[]
- FR=[]
- MC={'рыба': ['100'], 'мясо': ['120']}
- RC={'рыба': ['3'], 'мясо': ['2']}
- for j in RC.values():
- for y in j:
- y=int(y)
- FR.append(y)
- for i in MC.values():
- for x in i:
- x=int(x)
- FM.append(x)
- for i in range(0,len(FR)):
- FG.append(FR[i]*FM[i])
- for key in MC.keys():
- GC.append(key)
- GC=dict(zip(GC,FG))
- print(GC)
- In [8]: MC={'рыба': ['100'], 'мясо': ['120']}
- ...: RC={'рыба': ['3'], 'мясо': ['2']}
- ...:
- In [9]: foo = lambda dct_1, dct_2: {key: int(dct_2[key][0]) * int(dct_1[key][0]) for key in dct_2}
- In [10]: foo(MC, RC)
- Out[10]: {'мясо': 240, 'рыба': 300}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement