Somone help Functions 6


#1

Please help thank you!


did you define a function called by three?


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


#2

You're missing youe else keyword, though.

I find the print statement needless, though. But no harm. See Suggested code below:

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

Hope this helps! :slight_smile:


#3

it keeps saying did you define by_three


#4

I wanted you to also figure out that the instruction says to use the argument number and not n. Well,see full suggested code simplified below:

def cube(number): #cube function with number parameter
    return number**3 #returns cube of number
    
def by_three(number):
    if number % 3 == 0:
        return cube(number)
    
    else:
        return False

#5

k,and it says invalid syntax when i add else:


#6

With my last suggested code? :slight_smile:


#7

no its been doing that every time i try different code.


#8

Okay, restart page/browser and do exactly this:

def cube(number): #cube function with number parameter
    return number**3 #returns cube of number
    
def by_three(number):
    if number % 3 == 0:
        return cube(number)
    
    else:
        return False

#9

says the same thing :disappointed:


#10

i think its a bug or I'm doing some thing wrong


#11

thanks for trying to help :slight_smile:


#12

I don't know about a bug, but see: Somone help Functions 6


#13

it just shows loading screen?


#14

i will mess with it tomorrow.:sweat:


#17

Please, can you paste a copy of your screenshot with your code and error?

Thank you! :slight_smile:


#18


#19

You are yet to implement all I've said. For instance, your else keyword is missing. :slight_smile:


#20

when I put else: it says invalid syntax.


#21

Where exactly did you put else? Show us that with the syntax error message.


#22