Functions cube


#1

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

def by_three(number):
if result % 3 == 0:
return result

else:
    return False

cube(2)

above is my code.
error is the following:

Oops, try again. by_three(1) resulted in an error: global name 'result' is not defined


#2

solved it.

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

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

else:
return False


#3

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