0

I'm trying to create a program where python will take multiple inputs until the user enters "END". Each input must be on a different line. I'm still new and learning python/programming in general so is there any way to do this? and how would I turn the inputs into a list?

What a demo might look like -

What are your hobbies?

painting

hiking

drawing

END

0

1 Answer 1

2

You can read input with the input() function. You want to read till 'END' is entered by the user. So, read the input and check whether it is 'END'. If not append it to the list else exit the loop.

In codes you can do like this.

inputs = [] # list to store the inputs while True: # looping forever data = input('Enter the data : ') # read the data from user to variable data if data == 'END': # if END is read then exit the loop break else: inputs.append(data) # otherwise, append the input to the list print(inputs) # display the list. 

Hope this helps.!!

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.