Back

Explore Courses Blog Tutorials Interview Questions

Explore Tech Questions and Answers

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

0 votes
2 views
by (120 points)

my code

import simplejson as json
import os
if os.path.isfile("./ages.json") and os.stat("./ages.json") != 0:
    old_file = open("./ages.json","r+")
    data = json.loads(old_file.read())
    print("Current age is ", data["age"])
    data[0]["age"] = data[0]["age"] + 1
    print("New age ",data[0]["age"])
else:
    old_file = open("./ages.json","w+")
    data = {"Name":"nick","age":14}

    print("No age detacted .setting default age to",data[0]["age"])
old_file.seek(0)
old_file.write(json.dumps(data))
error-
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Please log in or register to answer this question.

Browse Categories

...