Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis+ 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 Respostas
+ 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!!