Hi all, I feel like this code should work, but keep getting the following error message: Oops, try again. factorial(3) returned 12 instead of 6. Any help would be appreciated!

My Code:

```
digits = []
def factorial(x):
while x > 0:
for digit in str(x):
digits.append(digit)
x -= 1
result = 1
for digit in digits:
result *= int(digit)
return result
```