How to get multiple inputs from users? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to get multiple inputs from users?

Idk how to get like 10 numbers from users in input at once and not use 10 different characters .help me with that plz

27th Oct 2020, 10:57 AM
tara
tara - avatar
6 Answers
+ 6
tara , you can use several approaches for this: (1) if the "numbers" you are talking about are all just 1-digit numbers, the input can be like: 153280 you can turn this in a list and do the conversion to int in a comprehension (use list(...) to split input to individual digits) (2) if the "numbers" you want to get have more than 1 digit, you can input them like: 1 14 0 8 -4 24 you can turn this input also in a list and do the conversion in a comprehension (use split('')). If you like you can also use an other separator to input your numbers.
27th Oct 2020, 11:45 AM
Lothar
Lothar - avatar
+ 4
You can use loops for that.
27th Oct 2020, 11:02 AM
Arsenic
Arsenic - avatar
+ 3
I couldn't understand from what u said 10 different characters. If you want to take 10 inputs in python, you have to either make 10 input statements or make a loop that iterates 10 times. And in the loop append the user input after taking input. Hope it helps...
27th Oct 2020, 11:02 AM
Steve Sajeev
Steve Sajeev - avatar
+ 2
You can just use for loop Inputs = [ ] for i in range(10): inputs.append(input()) Hope It Helps You 😊
27th Oct 2020, 11:05 AM
Hacker Badshah
Hacker Badshah - avatar
+ 1
Oh sorry for misunderstanding tara's question. I didnt understand. But when Lothar answered it, i understood what u were trying to ask. The only approach is as @lothar said.
27th Oct 2020, 11:49 AM
Steve Sajeev
Steve Sajeev - avatar
+ 1
Thank you all so much ❤
27th Oct 2020, 12:41 PM
tara
tara - avatar