The array journal
is set to empty automatically.
import os
import time
journal=[]
x=input()
for word in x:
os.system('clear')
print word,
else:
print ""
journal.extend(x)
print journal
The array journal
is set to empty automatically.
import os
import time
journal=[]
x=input()
for word in x:
os.system('clear')
print word,
else:
print ""
journal.extend(x)
print journal
Assuming you run this code through the python interpreter your array
(they're lists
in python, arrays
can be created using python modules) will be removed from memory when the script ends, you will need to save the values to a file or through some other method. You could try to add a while
loop to the code in order to keep prompting the user to input until they quit the program.
As a side note; even if the array
was still saved to local memory when the script ended, you are resetting the list
in the first line journal=[]
.
You have to save the information somehow if you’d like to have data persistency. Use the pickle module and create a file for the data to be stored and look up the docs for pickle for how to read and write.