Practice makes perfect


#1


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

Oops, try again. by_three(3) returned 1 instead of 27


it should work i don't understand the error msg


def cube(number):
    return number**3  

def by_three(number):
    if number % 3 == 0:
         return number / 3

    else:
        return False


#2

if the number is divisible by 3, you should return the cube() of number, not the number divided by 3


#3

what is wrong with my code it seems perfec to me?


#4

In the statement asks you to call "cube (number)" within the "if" statement if that number is divisible by 3, which in this case is.


#5

1)you need to take input first so at 9th line type
number=input()
2)and then at 10th line call the function by writing :
cube(number)
3)and also on line 6 you should write:
return cube(number)
4)if the code still does' t work feel free to contact me


#6

I think if he adds (number) after "cube" on line six, he should solve the problem.
I think because that's how my code is.

return cube(number)

#7

he also need to call the function for the program to be working if he copies this code to a python compiler and run the program it wont work as there are few errors in the program and the function was never called
so he need to call the function first


#8

The function has already been called. What is missing is what I quoted. Both for @betapro52360 both for @patilparesh3310


#10

A post was split to a new topic: Practice makes perfect


#11

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