0

I'm having some issues with these python functions. Whenever I run them, it saying function by_three is returning none. Any help would be appreciated.

def cube(number):
 result = number**3
 return result

def by_three(number):
 if number%3 == 0:
  cube(number)
 else:
  return False 
6
  • You mean return cube(number)? Commented Aug 19, 2017 at 18:32
  • Just return your call to cube(number) like @Mephy said. Commented Aug 19, 2017 at 18:33
  • It worked thanks a lot! Commented Aug 19, 2017 at 18:33
  • All the duplicates are about recursion - the canonical is stackoverflow.com/questions/17778372 - but this one clearly isn't. It seems to be a typo, but I think perhaps we need a canonical for this sort of problem? Commented Aug 13, 2022 at 13:04
  • I replaced the duplicate with the best I could find, but it's still not really accurate. Commented Aug 13, 2022 at 13:09

1 Answer 1

1

In the if case your function ends without returning anything. This is why you get None back. You probably meant:

def cube(number): 
    result = number**3 
    return result
def by_three(number): 
    if number%3 == 0:
        return cube(number)
    else:
        return False 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.