Practice makes perfect


#1

This is my code :

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

and i get this error:

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

any help would be appreciated.


#2

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:

```
<p>visible</p>
```

the backtick is located above the tab key on your keyboard


#3

@samosetragmail.com,
In your IF ELSE statement
you will have to use an extra 4-space indentation for the code-blocks
like

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

#4

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


#5

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.


#6

I see what you saying now. Thanks