Practice Makes Perfect - Why is my code not working😞


My name is Kiran and I don't know why my code isn't working.
I have checked the hint and literally copied the code it gives me and changed the 'prints' to 'returns'- I don't think it is this the problem though, as the error message says nothing like 'Oops, did you 'print' instead of 'return'?'. I think it has something to do with the function's argument.

def cube(number):
    return number()**3
def by_three(number):
    if n % 3 == 0:
        return True
        return False

I would be very thankful if somebody can help me.
From Kiran


On this line remove the parentheses ()

And here,

If your argument name is number use that to check if the number is divisible by three.


This is the answer:

def cube(n):
    return n**3
def by_three(n):
    if n % 3 == 0:
        return cube(n)
        return False

(It is okay if I put n. Doesn't make a difference.)

So, don't put the().

Have fun coding :smile:


Many thanks! :panda_face:


No problem. Happy coding :wink:


That worked perfectly! Thanks candycornlover1!


No problem just remember those little things can make your code go really wrong. :relaxed:


Thanks I appreciate it heaps for helping me out, people like you who willing help really make a difference, I'm sure you inspire many, hope your having fun coding (and helping others code), enjoy that rest of your day (or night).:+1:


No worries! Have a good day too! :slight_smile: :sunny: Or night :globe_with_meridians:


def cube(number):
return number ** 3
def by_three(number):
if number % 3 == 0:
return cube(number)
return False

That's what I got and it works. (You have to add the white spaces before the return on line 2, a white space before if, two whitespaces before the return on the sixth line and one whitespace before the return on the last line.


Please try not to post the answer.



Yeah, but I did explain what she did wrong. I just put what it has to look like.

~ Candy


Aha that is true! You are right


Thank you. But I should take your advice and explain more. I will do that more often.

~Candy :thumbsup:


I wanted to know. Do you know what flag means? :thinking:


Here look at this website. IT really helped me.


thanks @candycornlover1


No problem. :smiley:


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