+ 1
Python question
Is there anyway I can do multiple Inputs in Code playground?
2 Respuestas
+ 4
Ersin Koyuncu ,
additional to the description from Gulshan Mahawar, multiple inputs also can be done in one line. the input values have to be separated by space or comma like in this samples:
# for strings use input like: "tom sue bob liz"
# names is a list that takes the input tokens from split()
names = input().split()
print(names) # output => ['tom', 'sue', 'bob', 'liz']
print(names[2]) # output => 'bob'
# if input should be int nunbers, we have to convert input data (string by default) to int: "2 51 14 9 2 -7"
# numbers is a list that takes the input tokens from split() and int()
numbers = list(map( int, input().split()))
print(numbers) # output => [2, 51, 14, 9, 2, -7]
print(numbers[3]) # output => 9
+ 3
Ersin Koyuncu
You can do in Sololearn, but you have to give all your inputs at once in the beginning separated by line. For example:-
Code:-
a = int(input())
b = int(input())
print(a+b)
So your input must be like:-
25
32
And output will be:- 57