+ 2

Hi, who knows python well?

Is it possible to add multiple inputs on SoLolearn's terminal. If so, how can i? Have you ever tried ? a = input () b = input () print( a , b ) ???

13th Dec 2020, 5:59 PM
Berdakh
Berdakh - avatar
8 Antworten
+ 3
Berdakh Yes, just do int(a) + int(b)
13th Dec 2020, 6:00 PM
A͢J
A͢J - avatar
+ 4
Berdakh ,you have to give the input in seperate lines. like that: 5 6
13th Dec 2020, 6:11 PM
The future is now thanks to science
The future is now thanks to science - avatar
+ 3
#Enter each number seperated by a space, or leave empty for default inp = input().strip().split() or list(range(1,6)) print(f'There are {len(inp)} inputs') print(*inp, sep=' + ', end =f' = {sum(map(int,inp))}')
13th Dec 2020, 6:40 PM
Louis
Louis - avatar
+ 2
if you write, print(a,b) the program will work but not give the result you expected. the will first print the value of a then gap and then b.
13th Dec 2020, 6:03 PM
The future is now thanks to science
The future is now thanks to science - avatar
+ 2
Enter multiple inputs in separate lines.
14th Dec 2020, 7:39 AM
Sonic
Sonic - avatar
+ 2
You can use input_list = list(map(int, input().split())) then you enter like this: 1 2 3 4 5 # with whitespace Now you have got list of input numbers: print(input_list) [1,2,3,4,5] # output
15th Dec 2020, 5:45 PM
Abat Dauletbaev
Abat Dauletbaev - avatar
+ 1
I Am Groot ! Thanks for your respond but on the app (Sololearn), It is not giving some place to add second (third, etc) integer ???
13th Dec 2020, 6:06 PM
Berdakh
Berdakh - avatar
0
a=eval(input()) b=eval(input()) print(a+b) Input on separate line Ex: 1 *Enter* 1 Output: 2
15th Dec 2020, 12:28 PM
David Bukedi Diela
David Bukedi Diela - avatar