I am new to Python and relatively new to coding in general, I was just trying to write a test bit of code to see if a list could be appended, and then when that .py is reloaded the changes are saved into it?
I'm not sure if this is possible with lists without a decent amount more work, but none of my attempts have managed to get me there.
The test code I have at the moment is:
lDUn = []
lDPw = []
def enterUn():
usrName = input(str("Enter your desired username:\n"))
if usrName in lDUn:
print ("Username is already in use, please try again")
enterUn()
else:
print ("Username created!")
lDUn.append(usrName)
enterUn()
def enterPw():
pW1 = input(str("Enter your desired password:\n"))
pW2 = input(str("please re-enter your password:\n"))
if pW1 == pW2:
print ("Password created!")
lDPw.append(pW1)
else:
print ("Passwords do not match, please try again")
enterPw()
enterPw()
When lDUn
and lDPw
are checked for inclusion later on they register no problem, but when the program is closed and re-opened later they are gone.
I have tried making it writing the 'pW' and 'usrName' inputs into a .txt but have failed to get it to search those .txts for the specific strings later on. (but that is for a different question) Other than that I'm not sure what to do with my current knowledge of Python.