Not sure what to do next


#1

This is what I have so far. This was my first interpretation of the code but im getting an indentation error at my “else” statement and cant even get it to run. Any help would be much appreciated!

def cube(number):
return number ** 2

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


#2

Remember to give an argument,

return cube(number)

#3

Thanks @mtf. I am still getting an indentation error.

" File “python”, line 7
else:
^
IndentationError: unexpected indent"


#4

This is what I ended up with. Passed the lesson, but not sure if it was correct or not?

def cube(number):
return number **3

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

cube(30)


#5

Correct…

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

Call the cube function in your return statement…

return cube(number)

#6

Thank you for your help!!!


#7

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.