I was creating a simple program to review words in English and I had a question.
How can I save the words entered in the dictionary created for a future session? . When you close the program and reopen, all the words in the dictionary are deleted.
I tried to save it in a file.txt but at the time of reading the file to extract the dictionary it gives many problems.
Could you save the generated cache in the session and run it again the next time you load the program to not lose the dictionary?
Or maybe you could use a library or some other option that I do not know?
I would like it to be in a file and not resort to databases like MySQL.
#!/bin/python3
# -*- coding: utf-8 -*-
def repasar():
while True:
for d in x:
print ("palabra: %s" %(d))
ing = input("Escribe en ingles: ")
if ing == dic.get(d):
print ("correcto")
else:
print ("Incorrecto: %s" %(ing))
def agregar():
x=input("Palabra en español: ")
y=input("Palabra en ingles: ")
dic[x]=y
print (dic)
dic={}
print ("1. Repasar")
print ("2. Añadir palabra")
decision = input("Que quieres hacer? ")
if decision == "1":
repasar()
elif decision == "2":
agregar()
PS: I put the program in case it is necessary to find a solution. You can see that it is unfinished, I left it like that until I found a solution to the aforementioned problem.