Answer the question
In order to leave comments, you need to log in
How to add an entry to array[] so that it is saved?
I want to write data to an array "[]" which is in another file, but when I add data, the data is not saved.
import podop as pod
pod.n.append(4)
print(pod.n)
Answer the question
In order to leave comments, you need to log in
1. [] is not an array. And not an array, in general.
This is a list - a structure of sequentially arranged elements. Subsequence.
2. It is initialized every time the file is executed, created in memory and exists in memory. You start again - it is re-created.
3. The most direct and easiest way to save is to save a Python object (and a list is an object) to an external file using the pickle function .
4. You can also save in JSON, this is a more portable and versatile way. Google it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question