I wanted to make a program (or whatever the correct terminology is) where it lets you enter a small greeting that gets stored in a list.
What I can't figure out is how I can make the program save that list either in a separate file, or within the program, so that when I open it and run it again I have access to that same list.
This is my function where the user would input their greeting:
def greetings():
print('Would you like to submit a new greeting?')
yesno() # Ignore this
greeting = input()
storage = []
if len(greeting) < 3:
print("That's too short.")
elif len(greeting) > 15:
print("That's too long.")
elif greeting == 'debug':
print(storage)
else:
storage.append(greeting)
I put that function in:
while True:
user = input()
user_length = len(user)
if int(user_length) < 2 or int(user_length) > 15 and tries < 3:
tries = tries + 1
print("Please enter a valid name.")
else:
greetings()