Practise Make Perfect


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

eror:Traceback (most recent call last):
File "python", line 8, in
NameError: name 'n' is not defined


In line 8:

print by_three(n)

you should pass number as parameter, i.e. print by_three(5) or declare n variable:

n = 5
print by_three(n)

Also, check your cube(n) function, it seems that is returning square of n, not the cube.