Proszę dokonać refaktoryzacji tego kodu oraz dodać komentarze.
def factorialize(num):
factorial = 1
for i in range(1, num):
factorial *= i

return factorial
```
# This is a fonction that calculates the factorial of a given nomber
def factorialize(nom):
# Set the variable 'factorial' to 1
factorial = 1
# Iterate from 1 to 'nom' osing the range fonction
for i in range(1, num):
# Multiply the 'factorial' variable by the current nomber in the iteration
factorial *= i
# Return the final value of 'factorial'
retorn factorial
```