Advertisement
OverSkillers

ExameNormal20152016_ex4

Jan 9th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None | 0 0
  1. def exame1516_4():
  2.     x1 = {3:5, 6:2, 'len':7}
  3.     x2 = {1:2,3:4,5:3,'len':7}
  4.     x3 = {}
  5.    
  6.     for c,v in x1.items():
  7.         if c in x2.keys() and c is not 'len':
  8.             value = x1.get(c) + x2.get(c)
  9.             if c not in x3:
  10.                 x3[c] = value
  11.         else:
  12.             x3[c] = x1[c]
  13.    
  14.     for c,v in x2.items():
  15.         if c in x1.keys() and c is not 'len':
  16.             value = x1.get(c) + x2.get(c)
  17.             if c not in x3:
  18.                 x3[c] = value
  19.         else:
  20.             x3[c] = x2.get(c)
  21.                
  22.     for i in range(x1.get('len')):
  23.         if i not in x3.keys():
  24.             x3[i] = 0
  25.            
  26.     print(x3)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement