Oct-31-2018, 04:14 PM
(This post was last modified: Oct-31-2018, 04:16 PM by Gribouillis.)
(Oct-31-2018, 12:47 PM)Ablazesphere Wrote: Please show me if you have any idea to update a program permanently.You need to use a module for data persistence. There are the pickle module or the json module in the standard library, but you can also use third party modules such as tinydb
from tinydb import TinyDB, Query record = Query() db = TinyDB('db.json') if db.search(record.name == 'lst'): lst = db.search(record.name == 'lst')[0]['value'] else: lst = ["Laptop", "Phone", "Python"] db.insert({'name': 'lst', 'value': lst}) user = input("Enter an element : ") lst.append(user) db.update({'value': lst}, record.name == 'lst')