+ 1
Why does this recursion code (python) give an error
def factorial(x): if(x==1): return x else: return x * factorial(x-1) n=input("enter a positive number") print(factorial(n))
3 Answers
+ 2
n=input(".......")
here what ever u give input thats a string...
u need to convert n to integer...
do this...
n=int(input("...."))
+ 2
I figured the answer out:
change n=input("....") to n=int(input("..."))
- 1
yep...
thats it...
ââ