6 function chapter please help


#1

please find the mistake

def cube(number):
return number**3

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

#2

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

#3

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

line number 3 showing problem


#4

File "python", line 3
def by_three(number):
^
IndentationError: unindent does not match any outer indentation level


#5

You return cube(number) but var 'number' don't exist in def 'by_three'.

This is correct identation:

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

#6

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