I have a database “records” within it documents of the type:
{ ..., ..., "grades" : {"good": "40.0", "bad":"22.0"}}
- I need to get into the document and define a variable as the sum of the “good” and “bad” grades.
- I don’t know how to get inside the imbedded doc,
I tried :
for i in records:
variable = i['grade.good']
But that doesn’t seem to work.
Secondly, the grades are strings, and I need to convert them to integers/
Again, tried
total = int(i['grade.good']) + int(i['grade.bad'])
But that it also wrong.
note that my strings are floating points
Help much appreciated!!
instead of
i['grade.good']tryi['grade']['good']retrieve data from dictionary properly
for float number