6. Practice Makes Perfect - PRINT


#1

https://www.codecademy.com/en/courses/python-beginner-c7VZg/1/5?curriculum_id=4f89dab3d788890003000096#

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)
    else:
        print "The number is not divisible by 3"
        return False

#2

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: "))
print(by_three(number))

#3

Ohhh - get it!!!
MANY THANKS


#4

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

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

else:
    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
)


#5

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


#6

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