6. practice makes perfect help


#1

I think I am doing it right but i am getting an error.

https://www.codecademy.com/courses/python-beginner-c7VZg/1/5?curriculum_id=4f89dab3d788890003000096

I get error message "Oops, try again. by_three(3) returned None, did you remember to return the result?"

I expect it to work, but it doesn't.

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

#2

There are paths that your by_three function can take which does not come across a return statement, and therefore not return anything (see your error message)


#3

So what should i do to fix it?
should i use a raw_input


#4

You'd need to argue for why that would help.

As said earlier, the problem is that your function does not always return a value, the solution to that is to consider all things that your function might do and make sure that in all those cases it's going to return something


#5

so i just did this one, what you are missing is a return after your if. since its what the class is asking you for.


#7

Thanks to everyone especially jole80 i solved my problem and can move on now


#10

Thanks a lot for your help


#11

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