Practice Makes Perfect


#1

I already completed the lesson, but there's a question.

In order to understand my question I'll copy&paste my code:

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

In number 04 of the instructions they asked us to add this code if number % 3 ==0
04. if that number is divisible by 3 (...)

Isn't there a smiliar way to code, like without modulo but with the /? I tried it like this if number/3 and not 0/3
But it didn't work. Thanks.


#2

Well simply dividing it like that wouldn't work because then you are just asking if you can divide the number by three, which we can do for any number regardless of it is divisible or not.


#3

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