I’m trying to one by one, go through each json object and subtract 1 from each value, but I’m not sure where to start…resources on this specific thing are scarce online so I came here…
{
"12345678910":32,
"10987654321":21 // after one loop will change to 31 and 20
}
json_file=json.load(file)
for object in json_file:
# subtract 1 from value
2
Answers
You can leverage Python
typing
module to accomplish this complex task.doctest
too! Comments for explanation!Some users commented that the above function was too overcomplicated. Maybe with recursion the solution becomes more clear:
You’re almost there. Inside the
for
loop you just need toand then:
Full code: