Doubt why all test cases are not passing even when output is coming right

this is the question

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

Input Format
A list of integers to be processed

Constraints
All numbers input are integers between -1000 and 1000.

Output Format
Print all the numbers before the cumulative sum become negative.

Sample Input
1
2
88
-100
49
Sample Output
1
2
88

this is the program i have written

s=[]
while True:
n=int(input())
if n<1 or n>1000:
break
else:
s.append(n)

for i in s:
print(i)

please tell what is wrong why test cases is coming wrong

please reply asap

Hello @coding123c,
The question is when the sum becomes negative that is <0 ok.
And why do you need to create s[] array correct approach would be to just maintain a sum variable initialize to sum and keep adding the input digits to till until the sum>=0 if it becomes less then 0 then break.
Try to code this approach.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.