Replies: 2 comments 3 replies
-
Hello. This is not a Python support forum, but here is what ChatGPT says: Your code has a couple of issues. Firstly, you are trying to use import json
stuff = ["items", "other things"]
# Use a string for the filename
filename = "stuff.json"
# Correct the indentation for the json.dump
with open(filename, "w") as outfile:
json.dump(stuff, outfile) This code will create a file named To run this script in VS Code:
You should now see a ["items", "other things"] |
Beta Was this translation helpful? Give feedback.
-
Hi @skulimerp You all doing good! but you need to separate the stuff.json file name with double quotes(""), because in this quotes you provide path to file you want to read ("r") or modify ("w") here is the correct version:
after script execution you will notice that a stuff.json file appeared in root path Good Luck! |
Beta Was this translation helpful? Give feedback.
-
please help just learned python and I don't know what I'm doing wrong I'm trying to make a new json file
my code is below I'm using VS and I don't know if its VS or me but when I run it nothing happens sometimes it will tell me "'list' object has no attribute 'json'" i know its dumb but i need help understanding if anyone has any tips please let me know
import json
stuff = ["items", "other things"]
with open(stuff.json, "w") as outfile:
json.dump(stuff, outfile)
Beta Was this translation helpful? Give feedback.
All reactions