def fact(num):
if num == 1:
return 1
else:
return num * fact(num-1)
test = int(input())
for i in range(test):
num = int(input())
print(fact(num))
With this logic it seems you are trying to compute factorial of a number.
Now test your input for different numbers and most importantly for zero (0).
What should your return statement carry when input is zero? I think you know how to resolve it.
1 Like
I am also getting the same error. Do you know how to resolve that?
Post those errors with input
print(input())
how can even this line throw any kind of error. But that’s showing NZEC error (end of file)
yes
In here you have to provide input. The NZEC error only comes when you run a program without input