I think your main problem is that you didn't properly understand how the factorial is calculated.
Please, read it here.
So based on this, you could implement factorial with a for loop like this:
def factorial(n):
product = 1
for i in range (2, n + 1):
product *= i
return product
I'd suggest trying to implement it with recursion as well (the function calls itself, instead of a for loop).