6. Practice Makes Perfect - PRINT



Someone ask exactly the same but unfortunately the topic is closed and I didn't understand it right now.
The code works except the printing function - why and how can I fix this?
Many thanks!

number = raw_input("Enter a number")

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


In order for your code to work move your number variable to the end of your code and convert it into an integer,

number = int(raw_input("Enter a number: "))

Note: You also need to call your function to see the result,

number = int(raw_input("Enter a number: "))


Ohhh - get it!!!


i got a problem here
def cube(number):
return number ** 3

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

    print "is not di"
    return False

that's my coda and in the console says "Invalid syntax."
what i've done wrong? (Sorry, english is not my main language but i am doing my best to learn coding


Look carefully through your spaces before each line (tabs)!


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