No error?!?


i am stuck at this :cry:

it shows a syntax error

def cube(number):
    if number % 3 == 0:
        return number**3
def by_three(number):
     if number % 3 == 0:
        print "number is divisible by 3"
        print "number is not"


sorry i mean it shows no error


What is the problem then?


well it says this

Oops, try again. cube(1) returned None, did you remember to return the result?


It seems to be saying how it wants your function to behave differently. Do you disagree with what it says? Do you understand what it says?


so how can i fix it??


i do not im sorry:sweat:


Well you need to line up the instructions that you're writing (your code) in such a way that when executed, the desired result is produced.

So, you need to decide what it should be doing and then compare what it does to that. If you execute your function manually with number=1, then what does it return? Where should it have acted differently?

What should the function return for number=1?
Explain to a nearby inanimate object, such as a rubber duck, how your function would arrive at the correct result.


ok hold on let me see :worried:


sorry but i dont really understand what you want me to do


Think about what your function should do. What is the purpose of the function? What should it do?

If you were the cube function and I tould you 1, what would you reply with?

Now read your code, how does it differ from how you yourself perform that same task?


Python has no mind of its own, no idea of what you want it to do. It does exactly as you say.

So it won't just "click" and suddenly be correct, it doesn't know when something is right or wrong.

If you read your code, what are you telling it to do? What should it do? Is that what you are telling it?


i do appolagiser but i do not know what you are trying to tell me


Have you read your code?

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

What does it translate to in plain English?
What does it say should happen when number is 1?


You have a condition there.
What happens when it's true?
What happens when it's false?

What should happen in either case?
Which values make it turn true and which make it turn false?