Practice Makes Perfect - IndentationError


#1

def cube(number):
    return cube(number ** 3)
def by_three(number):
     if number % 3 == 0:
    return cube(number)
else:
    return False

So this is the my code and it all comes down to line 5 - IndentationError: unindent does not match any outer indentation level.

Any help would be highly appraciated.


#2

after a if you should always have indention:

if condition:
   print True

#3

Ok, thanks. Almost there. Now I just have to figure out what's wrong with " else: ".


#4

okay, it would be better if you can figure it out yourself, so give it a go.

If you need more help, post an updated version of your code


#5

This is what I ended with, but I'm still missing a puzzle.

def cube(number):
    return cube(number ** 3)
def by_three(number):
     if (number) % 3 == 0:
         print True
         return cube(number ** 3)
     else:
         print False
         return cube(number)

cube(1) resulted in an error and I did try to go over other posts and resources but only got more confused


#6

your cube function should return the cube of number, you shouldn't call the cube function inside the cube function


#7

It took me way longer than I expected but I got through. Thank you very much. Guess I still need to read a lot about functions to understand it.


#8