Not able to pass all test cases in simple input

n=input()
list=n.split()
sum=0

for num in list:
sum += int(num)
if(sum>=0):
print(num)
else:
break
this is the code which i wrote and is not able to pass all cases. Help!

Hi @ishaan.singh2k
Please refer to the following code :

s=0

while(1):

    n=int(input())
    if(s+n<0):
        break
    print(n)
    s=s+n

Hope this might help :slightly_smiling_face:

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.