python - How to add particular element of dict -


sleeps=[{"summaryid ": "x209bf59-59b0c5a8-585c ",           "validation ": "auto_tentative ",           "durationinseconds ": 22620,           "starttimeinseconds ": 1504757160,           "awakedurationinseconds ": 900,           "starttimeoffsetinseconds ": -14400,           "deepsleepdurationinseconds ": 8160,           "lightsleepdurationinseconds ": 13560},         {"summaryid ": "x209bf59-59b0c5a8-23a0 ",           "validation ": "auto_tentative ",          "durationinseconds ": 9120,           "starttimeinseconds ": 1504757160,          "awakedurationinseconds ": 300,           "starttimeoffsetinseconds ": -14400,           "deepsleepdurationinseconds ": 1680,           "lightsleepdurationinseconds ": 7140}        ]  res = sum([x["durationinseconds"] x in sleeps])  print(res) 

this throwing keyerror.

the key want modify has redundant space in dict definition

"durationinseconds "                   ^ 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -