# Factorial - message error but my code works well

#1

My code works well but I've got a message error:
"global name 'reponse' is not defined" error

Could you help with that please?

Note that I'm using the french version.

``````def factorielle(x):
total = 1
for i in range(x):
total *= (x - i)

print factorielle(0)``````

#2

this exercise is bugged, your code is fine.

Try this:

``````def reponse(x):
if x < 2:
return 1
else:
return x * reponse(x - 1)
def factorielle(x):
total = 1
for i in range(x):
total *= (x - i)

print factorielle(0)``````

it should work

or something a little shorter:

``````def factorielle(x):
total = 1
for i in range(x):
total *= (x - i)
reponse=factorielle
print factorielle(0)``````

#3

yes, that worked, thanks!

#4

``````def factorielle(x):
total = 1
for i in range(x):
total *= (x - i)
reponse=factorielle
print factorielle(0)``````

this would allow you to cheat the entire exercise together (abusing the bug in validition):

``````def factorielle(x):
return x
reponse=factorielle
print factorielle(0)``````

anyway, you understand it (that is the most important bit). And now with a little hacking you got around the exercise as well. Well done

#6