How can I make a permanent 2d list(Python)

71 views Asked by At

In my code, I want to have a list that when the file is closed, I can still access the filled list when rerunning it. For example, if I have a list = [1] in a file, I want it to be able to be filled permanently. Idk if that makes sense. Like list = [1] turns into list = [1,2]. Probably hardcoded.

1

There are 1 answers

0
Gabriel Baia On

I ended up using with open('Tasks.txt','r') as file: data = file.readlines() to open the file

line = data[i].split(" ")

to get a specific line and

        file.writelines(data)

to write it back into the file or``` with open('Tasks.txt','w') as file: file.writelines(data)