+ 6

Making dictionary as user input, then save it into json file

It works for only one time. I want to save keywords and values as much as I want. I want to create a dictionary database. The file saves the dict, but if you start the program again, the file resets. https://www.sololearn.com/post/1431958/?ref=app

18th Dec 2021, 3:33 PM
Amit Gajare
Amit Gajare - avatar
5 Respostas
+ 4
Using "w" in open() overwrites any content that is in the file. Use "a" to append. https://www.w3schools.com/JUMP_LINK__&&__python__&&__JUMP_LINK/python_file_handling.asp
18th Dec 2021, 3:46 PM
Simon Sauter
Simon Sauter - avatar
+ 2
Lol did you even read the code? My code doesn't have users deal with dictionary syntax silly. It creates , reads, and writes a dictionary to/from a file with a command line interface. Im not gunna write your code for you. But if you take some time and figure out how mine works, you can make your program.
18th Dec 2021, 4:01 PM
Slick
Slick - avatar
+ 2
Read the file. Add to dictionary. Write the file.
18th Dec 2021, 4:04 PM
Simon Sauter
Simon Sauter - avatar
0
Look at this, this program reads and writes dictionaries to a file using the json library https://code.sololearn.com/c7ZKwzGuu5O5/?ref=app
18th Dec 2021, 3:51 PM
Slick
Slick - avatar
0
Simon Sauter Not work bro output : {"amit": "hello"}{"hello": "amit"} want this type of output : {"amit": "hello", "hello": "amit"}
18th Dec 2021, 3:59 PM
Amit Gajare
Amit Gajare - avatar