Practice Makes Perfect error msg


#1

Hi

In the exercise Practice Makes Perfect I am getting an error msg, my code works as I want it too but I am getting an error msg that is not allowing me to proceed. I do not want to skip ahead in case there is something I am missing.

Exercise Link

Error Msg: cube(1) returned '1 cubed is 1' instead of 1.

Thanks in advance of any help you can provide.


number = float(raw_input("Please enter in a number: "))

def cube(number):
    cubed = number*number*number
    return "%.0f cubed is %.0f" % (number,cubed)

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

print by_three(number)


#2

Hi

In your function cube, you return a string instead of just the value, as explained by the error message.

If you really want to print your sentence, you could print it but you should return only the value. By the way, you have the same problem in the if of your function by_three, you should print the sentence but return only the value. The else in the function by_three is correct.
Cheerio


#3

A post was split to a new topic: Practice makes perfect


#4