I'm not receiving output


#1



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


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

And in the Console it says None


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


#2

or else is this correct?

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


#4

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

Is this correct?


#5

kindly reply @chipjumper36731


#6

Hey sorry for taking long. Check this out:

The equal operator you used in there is to check if the values on either side of the variable is the same, we want this operator:

=
which assigns values to objects. Fix that. Also read the directions, it says to:

That if that number is divisible by 3, by_three should call cube(number) and return its result. Otherwise, by_three should return False. You didn't do that in our second function.


#9

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

new code .. is this correct


#10

Remember we only return it if the remainder of the number being divided by three is zero. So the line I pointed out should be like this:

if number % 3 == 0:

#11

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

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

and console says
None


#12

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

This should be what your final code should look like. You keep fixing things in your code but, then deleting them when I point out another problem. :confused:


#13

I'M EXTREMELY SORRY.

now i receive output as False
None

but i don't understand why do we use print by_three(1).. what the 1 resembles.

and i can understand return number**3 but should we need to include number = number **3.. what does the statement number = number **3 means


#14

Yeah I made a mistake about that part. Forget whatever I said about that. As for this:

That means we are testing out the by_three function with the input as 1, and printing it. And don't be sorry. :slight_smile:


#15

Why my console is still "none" after typing that?


#16

kindly send your code. we shall check it :stuck_out_tongue:


#17

but i recieve only output as False and then none in the second line..


#18

@chipjumper36731

can u say how the output is shown in console


#19

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