First and for most, it is important to realize that the moment a return keyword is reached, something is returned, and the function ends!
right, now first this bit:
return n * (n*n)
i would indent the return line, so it is inside the function.
then your by_three function:
if n % 3 == 0:
print "number is divisble by 3"
print "number is not divisble by 3"
return cube(n) should re-indented so it is inside your if statement.
i would put
print "number is not divisble by 3" before
return False, since functions end when return is reached.
I would put the function call (
print by_three(3)) outside and after the function.
You do understand how python deals with indentation? What indentation is, and how important this is in python since no brackets are used