I found a code that works for this task, which seems way easier than what I came up with, but I still want to understand why my code isn't working. Is my formatting off? Did I introduce y in the wrong place? Am I asking to return the right value? Is my while loops actually looping at the right time?
The error I'm getting is: "Oops, try again. factorial(3) returned 3 instead of 6"
So I figure my mistake must not be too far out there..
def factorial(x): y = 1 while x >= 1: y = x * y return y x -= 1 else: if x == 0: return 1
Thank you in advance.