SIMPLE INPUT Problem

Description: Given a list of numbers, stop processing input after cumulative sum of all the input becomes negative.

Code:
x=input()
list=x.split()
sum=0

for num in list:
sum += int (num)
if(sum>=0):
print(num)
else:
break

This code works fine in jupyter notebook but not in the compiler given here. It shows some error. Please, help me out with this!

I am having the same problem.
Did u find a solution for this problem?

Even I’m facing the same problem

@jatinkatyal13 can you check if there are any issues in online compiler ?

sum=0
while(sum>=0):
N=input()
sum+=int(N)
print(sum)

the above code is mine, working fine on my computer.But when i try on codeblocks it shows an error.
can anyone tell me what is wrong?

sum=0
while(sum>=0):
N=input()
sum+=int(N)
print(sum)

can anyone tell me what is wrong?
code works fine on my machine,but shows error on codeblocks!

i am also facing the same problem. It is running successfully for 1 testcase but for the remaining testcases,I’m getting wrong output

iam facing the same problem , can somebody tell me the solution.
evertime i take input this error occurs
Traceback (most recent call last):
File “source”, line 1, in
n=input()
EOFError: EOF when reading a line

1 Like

Heyy all
I was also facing the same problem. This is because in that question input is given in multiple lines. So we have to read input accordingly.
I tried this in Python3 and it worked quite well for me
numbers1="" //An empty String
while True:
try:
p=input() //Input new number(in form of string)
except EOFError: //If no input found then break loop
break
numbers1+=p+" " //Else add that number to string with " "(space)
numbers=[int(i) for i in numbers1.split()] //convert string to numbers and store it in list
Hope it helps :slight_smile: