LearnPy Hub
← File Handling problems
Hard

Update a JSON File

Save {"name": NAME, "visits": 0} to user.json. Then n times: load the file, add 1 to visits and save it again. Finally load it and print it with json.dumps(data, sort_keys=True).

Input

A name, then n.

Output

One line.

Sample 1

Input
Mim
3
Output
{"name": "Mim", "visits": 3}

Sample 2

Input
A
0
Output
{"name": "A", "visits": 0}
solution.py
Output appears here
Update a JSON File · Python practice problem · LearnPy Hub