What's Wrong with my function? can somebody help me?


#1

I Have Problem with lesson python, in the Practice Makes Perfect in the function
there’s my code

def cube(number):
  n = number
  if n % 3 == 0:
    print "n divisible by 3"
  else:
    by_three(n)
  return number

def by_three(number):
  print "n is not"
  return number

cube(6)

And the error result is “cube(2) returned 2 instead of 8”


#2

Oh Sorry it’s Done

def cube(number):
  return number**3

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

#3

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