Jan-06-2021, 09:54 PM
Are you looking for something like this?
A = [] def update_dict(dname, value, clear=False): if clear: dname = [] dname.append(value) print(f"Dict contents: {dname}") update_dict(A, 44) update_dict(A, 35) update_dict(A, 55, clear=True)
Output:Dict contents: [44]
Dict contents: [44, 35]
Dict contents: [55]