I cant understand why my test cases are not passing?

I’ve tried and it works for my test cases, idk why its failing hacker blocks test cases.
numbers=[int(n) for n in input().split()]
count=0
co=len(numbers)
for n in range(co):
count=count+numbers[n]
if(count<0):
for i in range(n):
print(numbers[i])
break

if(count>=0):
for i in range(co):
print(numbers[i])
This is the code
Any reason why hacker blocks test cases are failing?

Hey,

You are not taking inputs in the required format.
Inputs are supposed to take in next lines. like this
1
8
10
-88
100

But you are taking inputs as 1 8 10 -88 100.
It means you are processing only one element i.e the topmost element.

To correct this, use a while loop till the sum is non-negative, and keep asking for new input again and again. And at last print the numbers.

pesudo code:

make an empty list
sum=0

iterate till sum>=0
   read input
   sum+= input
   append input to list

outside loop print the list

Thanks :slight_smile: