I have created a function factorial(x) that aims to use a while loop to calculate and return the factorial of the argument x. However, when I submit this function, I receive the error message "Oops, try again. factorial(3) returned 3 instead of 6."

Here is my explanation of the function/what I expect to happen: At the beginning of the function, two variables are created: "num," which has x as its value, and "empty," which has a value of 1. The while loop is introduced so that, as long as the value of num is greater than 0, the result of the multiplication of num by empty will be stored as the new value of empty, the value of num will be decreased by 1, and the resulting value of num will be returned. When num is no longer greater than 0, the else statement will return empty.

This is not, however, what happens. An explanation of why this function doesn't work would be much appreciated. Thank you!

```
def factorial(x):
num = x
empty = 1
while num > 0:
empty = empty * num
num - 1
return num
else:
return empty
```