2

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

Yolo Gamer
  • 53
  • 1
  • 1
  • 5
  • I don't about the multiline input however for the output, you could concatenate the inputs to format it the way you want as a string or a list – Yujin Kim Oct 15 '19 at 10:57

2 Answers2

1

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']

Anonymous
  • 659
  • 6
  • 16
  • this doesn't do multi line input. this lets the user answer multiple inputs one at a time. – Yolo Gamer Oct 15 '19 at 11:09
  • @Yolo Gammer Then you can enter input by comma separated and then split using comma and use for further processing – Anonymous Oct 15 '19 at 11:13
  • i am trying to make my code user friendly so commas are out of the question because there can be some confusion and there is a higher chance human error – Yolo Gamer Oct 15 '19 at 11:15
  • @Yolo Gammer Then its difficult to get multi line input.We cant use the enter as a separator – Anonymous Oct 15 '19 at 11:19
  • Enter doesn't have to be used as a separator because the user will click on the line they want to enter data into – Yolo Gamer Oct 15 '19 at 11:21
  • I don't think it is possible with input(). One better way ask question first and then iterate loop 5 times and append answers. – Anonymous Oct 15 '19 at 11:25
  • the input can be in other forms e.g.text boxes/buttons or extra modules i just need to have a user friendly input that will let the user enter data into multiple lines. – Yolo Gamer Oct 15 '19 at 11:29
0

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)
Saeed Ahadian
  • 212
  • 2
  • 4
  • 14
  • this doesn't do multi line input. this lets the user answer multiple inputs one at a time. – Yolo Gamer Oct 15 '19 at 11:08
  • @Yolo Gamer, if you want the user to be able to click on a question and type the answer, I'm afraid it's not feasible given the command-line interface. You may need to use a gui. – Saeed Ahadian Oct 15 '19 at 11:28