I’m having an issue with my code, and not sure whether it’s a glitch in the system or my own error. My code works in the console when I issue a print command… but I’m getting the following error message.
‘by_three(1) returned ‘False’ instead of False’
Here are the instructions.
1. First, def a function called cube that takes an argument called number. Don’t forget the parentheses and the colon!
Make that function return the cube of that number (i.e. that number multiplied by itself and multiplied by itself once again).
Define a second function called by_three that takes an argument called number.
if that number is divisible by 3, by_three should call cube(number) and return its result. Otherwise, by_three should return False.
Don’t forget that if and else statements need a : at the end of that line!
And, here is my code:
def cube(number): return number ** 3 def by_three(number): if number / 3: return cube(number) else: return "False" print by_three(21)
I just added the last print command in this last round of testing to see whether it simply needed a defined number to work. With the print command, I do get the correct answer in the console box, however, I still get the error message.
I do not understand the error message, but I have tried it both with single quotes and double quotes. I’m stumped! Please help!