hello, i am new to python. Can you please explain to me why this function is not working?
the output is 12 when it is suppose to be 24
def factorial(num): for i in range(1,num): factorial = num * i return factorial print factorial(4)
after me looking at solutions for this particular factorial problem, how come this function work:
def factorial(num): factorial = 1 for item in range(1,num + 1): factorial = factorial * item return factorial
as opposed to the above one.