I understand the initial instructions of computing a factorial beginning with defining a function first. But once the solution is provided I’m lost… Here it is:

def factorial(x):

total = 1

while x>0:

total *= x

x-=1

return total

Why do we keep adding the total variable when creating a function? I don’t understand. Can you please break this down and explain it to me as simply as possible. Thanks!