Practice makes perfect


This is my code :

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

and i get this error:

File "python", line 5
return cube(number)
IndentationError: expected an indented block

any help would be appreciated.


after a function, if and else (anything that ends with a colon), you should indent:

if condition:
    #python do something

for next time, use one of the two following options to make your code/indent is visible:

select your code and press ctrl + shift + c (or cmd + shift + c if you use a mac)

if this instructions are unclear, you can also insert 3 backticks before and after your code, like so:


the backtick is located above the tab key on your keyboard

In your IF ELSE statement
you will have to use an extra 4-space indentation for the code-blocks

if (number) % 3==0:
    return cube(number)
    return False


Thanks for your respond. I don't see the difference between mine and yours tho


what @leonhard.wettengmx.n and @stetim94 are saying is that right amount of whitespace/correct indentation is very important in python, your code is not indented properly.


I see what you saying now. Thanks