Q in Practice Makes Perfect



I think I get the code right, but it always returned error. Please help me! Thank you.


Hi @sherwincsy617,

The main error in your code is a syntax error - you missed out a : (colon) at the end of your if statement! :frowning:

Even so, your code will not pass, because you have other errors in your code. For example, do check the argument which you are using for your function - is it in accordance with the instructions?

Also, when assigning n**3 to a variable, should you assign it to the function? Does what you return in the cube(n) function make sense?

Feel free to clarify anything if need be :slight_smile:


at the end of a if there should be a colon:

if condition:

and just like else, the return should be indented properly so it inside the if statemetn


Thank you for all the useful advices, I change all the n to numberand add colon at the end of my if statement. But the code didn't work:sweat: and new error occurred.What's wrong with my code?
Thank you a lot!


Thank you for the tips!


Oh, you forgot to return the cube of the number in your cube(number) function.

P.S. the second line, cube(number) == number **3 is also problematic because a) it shouldn't be an equal sign (==) , but rather an assignment sign (=) because we are trying to assign number^3 to a variable before returning this variable later on at the end of the function and b) I recommend that the variable name be changed to something else aside from the function name, cube(number).


Thank you! It works!