0

I would like to have my program store something in a list, and no matter what always have it in that list whether the program is restarted and so on.

Ive already tried the .add function, but I cant have .add on a list.

useradd_list = []

UserQuoteAdd_str in addquote_list:
        UserQuoteAdd_str = raw_input("What is your quote?")
        useradd_list.append(UserQuoteAdd_str)

What I need is a function that will save whatever the user types in memory and even if the program restarts, the list still has what the user typed.

amerivi
  • 23
  • 3
  • Think about files. You are still on Python 2 which will not help you some months down the line. – Austin May 04 '19 at 16:20
  • that doesnt help me but thanks? – amerivi May 04 '19 at 16:24
  • What you're looking for is called [persistence](https://docs.python.org/3/library/persistence.html). It involves storing the data in a file to the hard disk in some way or another. In the link you will find various standard resources on how to mantain state across runs. – Anakhand May 04 '19 at 16:34
  • You can read an example of writing to files in Python 2 [here](https://stackoverflow.com/questions/18984092/python-2-7-write-to-file-instantly). As your program's running memory is de-allocated upon termination, you'll need some other sort of resource (file, database, etc) to persist your data in, as @Anakhand is referencing. – jhelphenstine Jun 20 '19 at 22:59

0 Answers0