Skip to content
Advertisement

Different lines of input and output in Python

I’m currently trying to solve the max value problem. However, I’m now having a hard time getting many outputs at the same time. I try to use input().splitlines() to do it, but I only get one output. The test case and output need to have many lines just as the box’s examples. If anyone can provide me with some assistance, I would be very much appreciated it.

JavaScript

Advertisement

Answer

input does not handle multiline, you need to loop. You can use iter with a sentinel to repeat the input and break the loop (here empty line).

JavaScript

example:

JavaScript

NB. this code does not have any check and works only if you input integers separated by commas

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement