Getting an error for inputs in python

t = int(input())
while t!=0:
n = int(input())

Some code ahead

When I click on submit as well I get an error saying the NZEC. It runs well when I give custom inputs, but does not work after the submit button is pressed. Can someone please help me?
Thank you in advance

there is a indentatation error in 3 rd line one tab button is required

Oh, I am sorry I did not copy paste it correctly, inside the main code there is an indentation. Still it is giving me the same error

decrease t, t is remaining constant in your loop, do t=t-1.

1 Like

Something which I like to use,

for _ in range(int(input())):
   <Your code>
1 Like

Do something like this

t=int(input())
for i in range(t):
         n=int(input())

this way your code to take input would run t times which are the number of test cases .
You can also use while loop but then you have to change the value of t or you can also what someone else has suggested above with while

1 Like

Update t at the end of while body


t = int(input())
while t!=0:
      n = int(input())
      t=t-1

1 Like

Can you elaborate on the issue?

  • You are not updating the value of t
    Maybe, you’re missing this part
t -= 1

Also, if you’re still facing the issue, Share the problem code. We can check for actual problem.

1 Like

Thank you for your help, I was able to solve the initial problem now I am trying to optimize the code. Thank you once again

1 Like