Python Forum

Full Version: List creation and return in Function
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
def factors(x):
   L = []
   for i in range(1, x + 1):
       if x % i == 0:
            L.append(i)
    return L


num = 84


print (factors(num))
I'm trying to return a list in this function. Python gives me an error "IndentationError: unindent does not match any outer indentation level"

Could someone help me fix it? Many thanks in advance!
Line 6 is not properly indented.
Your indentation is all over the place.
At lines 2 and 3, it starts with 3 spaces, and then continues with 7, 12, and 4.
Thank you every one!