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
Post a Comment