fork download
  1. d = {'learning': {'DOC1': 0.14054651081081646,
  2. 'DOC2': 0,
  3. 'DOC3': 0.4684883693693881},
  4. 'life': {'DOC1': 0.14054651081081646,
  5. 'DOC2': 0.20078072972973776,
  6. 'DOC3': 0}
  7. }
  8.  
  9. d['sum'] = [d['learning'][k] + d['life'][k]
  10. for k in d['learning']]
  11. print(d)
Success #stdin #stdout 0.01s 9992KB
stdin
Standard input is empty
stdout
{'learning': {'DOC2': 0, 'DOC3': 0.4684883693693881, 'DOC1': 0.14054651081081646}, 'sum': [0.20078072972973776, 0.4684883693693881, 0.2810930216216329], 'life': {'DOC2': 0.20078072972973776, 'DOC3': 0, 'DOC1': 0.14054651081081646}}