5 Answers
+ 7
Lisanewerk Mikiyas , do you want to take a multiple input in one go with input() like:
2, 4, 11, 0 / or could also be string, ...
If not, please be so kind and create a sample of input value, and what do you want to output. Thanks!
+ 5
If you want to input more than 1 value, it can be done like this. The values from input will be integer and are stored in a list:
You can use an input with split, map and int conversion or a list comprehension with int conversion:
(1) input with split(), int conversion:
inp = list(map(int, input('').split())) # input like: 1 3 12
(2) input with split(), int conversion and comprehension:
inp = [ int(i) for i in input().split()] # input like: 1 3 12
Both versions have the result of: [1,3,12]
+ 1
I dont think I understand, can you explain or provide an example?
+ 1
Steven M i mean how could we take multiple input in a single line from the user....
For example:
Height=input()
This accepts one height variable....my question is how could we take multiple inputs with space separated in the single line
+ 1
Lothar thanks i need that exact answer