No error?!?


#1


i am stuck at this :cry:
https://www.codecademy.com/courses/python-beginner-c7VZg/1/5?curriculum_id=4f89dab3d788890003000096#

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"
     else:
        print "number is not"


#2

sorry i mean it shows no error


#3

What is the problem then?


#4

well it says this

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


#5

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?


#6

so how can i fix it??


#7

i do not im sorry:sweat:


#8

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.


#9

ok hold on let me see :worried:


#10

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


#11

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?


#12

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?


#13

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


#14

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?


#15

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?