how do i get multi-line input?

Viewed 75

I am trying to get the user to answer multiple inputs at once rather one at a time.

example: this asks for the users input one at a time

q1=input("question1: ")

q2=input("question2: ")

print(q1)

print(q2)

... question1: answer1
... question2: answer2

answer1
answer2

>>>

this is what i would like to do.

q1=input("""
question1: 
question2: """)

print(q1)


...question1: answer1
   question2: answer2 

[answer1,answer2]

>>>

by letting the user enter all inputs at once it will let them see all of the questions and they can make changes before they confirm their input.

my end goal is to be able to do this:

q=input("""
url:
resolution:
audio only:
file type:
download location: 
""")
print(q)

...url: youtube.com/video
   resolution: 720p
   audio only: False
   file type: mp4
   download location: C:\videos

[youtube.com/video,720p,False,mp4,C:\videos]

Edit:

i know how to get multiple outputs and concatenate them into a list.

multi output is not my main goal.

my main goal is multiple inputs all at the same time not one input at a time.

Edit 2:

if it helps the input can be in other forms e.g.text boxes/buttons or extra modules. example: https://i.stack.imgur.com/deKOb.png

2 Answers

Simple way to get multiple answers:

print ("Enter the below details")
question = ["url:","resolution:","audio only:","file type:","download location:"]
answer = []
for q in question:
    answer.append(input(q))

print(answer)

Output: ['www.google.com', '720', 'False', 'mp4', 'c:\\videos']

You can create separate lists of questions and answers. Then loop through questions for getting user input and add user input to the answers list.

questions = [
   "url: ",
   "resolution: ",
   "audio only: ",
   "file type: ",
   "download location: ",
   ]

answers = []

for question in questions:
    answer = input(question)
    answers.append(answer)

print(answers)
Related