-1

I want to ask the user for a message and then to store it to a variable x.

So

x = input("Insert a message")

but then I want the program to allow the user to write on the next line. The program should then store each line as a separate message.

Is there a way to make python create an infinite number of variables as necessary.

or do I have to put the messages into a string then strip it into a list.

Ali AzG
  • 1,861
  • 2
  • 18
  • 28

1 Answers1

0

You could create list to store all messages and then keep asking user for input in while loop until they let's say type "quit"

messages = []
while True:
    new_message = input('Insert a message: ')
    if new_message == 'quit':
        break

    messages.append(new_message)

print(messages)
Filip Młynarski
  • 3,534
  • 1
  • 10
  • 22