Functions, Practice Makes Perfect


When I try to run my code:

def cube(number):
  return number**3

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

It gives me the following message: by_three(1) resulted in an error: global name ‘n’ is not defined
What does this mean and how can I fix it?
Thank you.


Look at your undefined variable n. n was not defined. If we want to check if our number is fully divisible by 3, then we should use our parameter number to do this, so when we call our function, our argument will pass into the parameter and be checked there (in number). :slight_smile: Do you know what I mean?


Thanks! Managed to make it work


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