# Stuck on this Exercise, Not sure how to fix it

#1

<Look to the right of this box. That is how your post will look to everyone else.
I am having trouble with this function exercise and was wondering if anyone could point me in the right direction.

Oops, try again. by_three(1) returned 'try again' instead of False

I thought that because 9 is divisible by 3, that it would then call the correct function, but instead it returns try again.

``````number = 9

def cube(number):
return number*number*number

def by_three(number):
if number % 3 == 0:
return cube(number)
else:
return 'try again'``````

#2

here:

``return 'try again'``

you should return boolean value False

the exercise tests your code with multiply numbers to verify your function works correctly

A function executes the moments its called, you never call the function? So, you won't see any output even though you define number with a value of 9 at line 1

#3

Thank you for the quick reply!
I got it to work, after a lot of alteration.

May i ask why that should return false instead of a string? wouldn't you want the code to tell the user it entered something invalid?

#4

you currently input the numbers? So, no need to inform the user. False is easier to work with to see that the number is not divisible by 3 (i think its also for the exercise easier to validate with False then a string)

Codecademy is great to learn how to code, not to learn program design

#5

One last question.

"

I have just started this codeacademy lesson plan, and I have learned how to code in FORTRAN 95. But my reason for doing this is to hopefully get better at FORTRAN by learning another language that is more popular and that has more resources. I get syntax, but like you said, program design and learning how to take the syntax knowledge and implement it is challenging and is something that eludes me. Any advice?

#6

difficult. Ideally find someone who can teach you. (not me)

Build stuff, do code challenges (codewars has a lot of challenges)

#7

I am having issues with this as well. Here is my code.

number = 11

def cube(number):
return number * number * number

def by_three(number):
if number / 3:
return cube(number)
else:
return False

by_three(1)

#11

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