+ 1
Why is this code not working??
I was making a code which outputs factorial of a given number. For eg: 5! = 1*2*3*4*5 But there seems an error which I can't find. Could somebody help?? def factorial(n): result = 1 for x in range(1, n+1): result = result * x return result for n in range(1, 10): print(n, factorial(n)) factorial(5) OUTPUT: SyntaxError: Invalid Syntax
2 Respuestas
+ 1
Your space before result is weird and not considered a valid space in Python. Other than that, your code executes well.
+ 2
CarrieForle , Ok, I get it...
You made me understand in a fun way, Thanks a lot!!