Practice Makes Perfect


#1

The problem stated is was:

File "python", line 6
if number % 3 == 0:
^
IndentationError: expected an indented block

What does this mean and how do I fix it?

def cube(number):
    return number**3

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


#2

You need to indent

because python is extremely picky about indents and it is inside of the function cube. :slight_smile:


#3

thanks, can't believe i didn't notice such a simple error haha


#4

It's okay! It happens to everybody! You learn to avoid simple errors after you make them. A lot of editors automatically indent for us too. :slight_smile:


#5

I've tried to indent but my formula is incorrect. The error prompt says (Oops, try again. by_three(3) resulted in an error: maximum recursion depth exceeded)

Can you please assist? below is my code.

def cube(number):
return number**3

def by_three(number):

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

#6

it's all good!!!

solved the quesiton myself haha


#7

Thanks @kudo5 for the code
Really helped


#8