-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.

0

1 Answer 1

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)
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.