Spaces:
Build error
Build error
Update app.py
Browse files
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)
|