+ 1

Python question

Is there anyway I can do multiple Inputs in Code playground?

18th Jul 2025, 12:24 PM
Ersin Koyuncu
Ersin Koyuncu - avatar
2 Antworten
+ 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
18th Jul 2025, 2:25 PM
Lothar
Lothar - avatar
+ 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
18th Jul 2025, 12:30 PM
Gulshan Mahawar
Gulshan Mahawar - avatar