2
I need to read test cases of the following format:
3 1 2 3
4 52 2 1 87
10 51 32 1 36 21 34 32 12 34 45
200 (... 200 numeros separados por espaço)
and so on, where the first number indicates the amount of numbers that will come after. Each line is a test case, so I’d like to read each one up to the line break, how can I do that?
I know the line break is indicated by a ' n', but how can I go through this input string per line?
Edit: I think I figured it out with
import sys
while line:
line = sys.stdin.readline()
[operacoes em cada linha]
3 1 2 3
4 52 2 1 87
10 51 32 1 36 21 34 32 12 34 45
is a singlestring
?– ThiagoO
yes, it’s like you typed in the input, but there’s a line break at the end of each line
– Leila
I think I figured it out, I’ll edit the question
– Leila