Practice makes perfect


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

        return False


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


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


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.


1)you need to take input first so at 9th line type
2)and then at 10th line call the function by writing :
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


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)


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


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


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


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