Python 4-12 exercise

def fizz_buzz(input):
    divisible_15 = 15
    number = input
    if number % 3 == 0 and number % divisible_15 != 0:
        print("fizz")
    elif number % 5 == 0 and number % divisible_15 != 0:
        print("buzz")
    elif number % 15 == 0:
        print("fizz buzz")
    else:
        print(number)

Hi I am new in coding, just finish my python 4-12 section, here is my best solution, but it seems not clean enough, if possible to let my code cleaner?

Hi,
My solution:

def fizz_buzz(input):
    output = ""
    if not input % 3:
        output = "Fizz"
    if not input % 5:
        output += "Buzz"
    if not output:
        output = input
    return output

1 Like