lst = [int(i) for i in input().split()]
sum = 0
for i in range(len(lst)):
sum += lst[i]
if sum>=0:
print(i)
my code is showing eof error whlile copiling
in ur compiler but it is working in my compiler! why is it so?
Error while compiling
Hello, @Tanu_jain the error is due to the way of input you are taking.
See, in the ques the nos. are given line by line so we need to input every no. separately but the way you have used is used when we are given the input in the single line and we need to convert them into integers or separate the nos. from the string, that’s why we use split method to split the string along with space.
lst = [int(i) for i in input().split()]
so just remember that you have to take input line by line. So for that, you can use any while loop and if will simply run till your sums become neg.
I hope you understand this in case it is clear to you pls mark it as resolve and provide the ratings and feedback so that we can improve our services.
In case you want to ask something you can surely ask I will help you out.
Thanks 
Happy Coding !!
but we need any object to store the input values so that we can print those vale
arr = [] sum = 0 j = 5 while j > 0: inputs = int(input()) sum += inputs if sum >=0: arr.append(inputs) j -= 1 for i in arr: print(i)
now also it is showing same error
Why you have fixed this value of j and I tried running your code for a fixed value of j, it is working fine.
Please also check your spaces and tabs because indentation is much more important in python.
Try it out once again, if nothing happens I will help you out.
so should i give the condition that it will take value till sum becims neg for while loop
Yes, it will be like an infinite loop that will break when your sum will become negative