15. Practice Makes Perfect


#1
def cube(number):
    return number**3

def by_three(number):
    if number & 3 == 0:
        return cube(number)
    else:
        return False

Oops, try again. by_three(3) returned False instead of 27

What i'm doing wrong? Please help me with this lesson. :slightly_smiling:


#2

Hi, the symbol of module is that % not &


#3

@thelzrdkng,

You will want to use the so-called modulo operator %

9%3 You read it as nine modulo three is zero, as 9 divided by 3 has NO rest-value.
22%6 You read 22 modulo six is 4, as 22 divided by 6 will leave you with rest-value 4
10%5 You read 10 nodulo five is zero, as 10 divided by 5 will have NO rest-value

== discussions / opinions ==
http://stackoverflow.com/questions/12754680/modulo-operator-in-python
http://stackoverflow.com/questions/5584586/find-the-division-remainder-of-a-number


#4

Thanx guys, it finally works! I'm so inattentive. ^^