+ 2
Why doesn't the value is stored in the list??
I made a program in python which search for a name in the list and outputs its full details which is in the second list called details and I have also added a feature to add additional through the user input without modify the script itself but the value is not stored permentaly when I close the program and run it again it is back to the stock list why is that
1 Odpowiedź
+ 3
Because list are created in the RAM (the data in RAM are lost when the program ends.)
If you want them to persist you have to store them in the Hard Disk.
You can do that in python using pickle:
import pickle
# storing 'mylist'
mylist = [1, 2 , 3, 4]
file_name = 'myfilename'
pickle.dump(mylist, file,_name)
# getting the list again
mylist = pickle.load(file_name)