Nikhil0987 commited on
Commit
a45108a
·
verified ·
1 Parent(s): 0740981

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -1
app.py CHANGED
@@ -9,9 +9,10 @@ def add_to_json(hole):
9
  data = json.load(file)
10
  except FileNotFoundError:
11
  data = {"goals": []} # Create an empty "goals" list if the file doesn't exist
12
-
13
  new_item = {"Goal": hole}
14
  data["goals"].append(new_item)
 
15
 
16
  with open("test.json", "w") as file:
17
  json.dump(data, file, indent=4)
 
9
  data = json.load(file)
10
  except FileNotFoundError:
11
  data = {"goals": []} # Create an empty "goals" list if the file doesn't exist
12
+ if "goals" not in data:
13
  new_item = {"Goal": hole}
14
  data["goals"].append(new_item)
15
+
16
 
17
  with open("test.json", "w") as file:
18
  json.dump(data, file, indent=4)