# Python 4-12 exercise

**URL:** <https://forum.codewithmosh.com/t/python-4-12-exercise/5692>\
**Category:** Python\
**Created:** [June 24, 2021, 12:50pm UTC](https://forum.codewithmosh.com/t/python-4-12-exercise/5692 "2021-06-24T12:50:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![LouisLin](https://avatars.discourse-cdn.com/v4/letter/l/77aa72/32.png) [@LouisLin](https://forum.codewithmosh.com/u/LouisLin)\
**Post date:** [June 24, 2021, 12:50pm UTC](https://forum.codewithmosh.com/t/python-4-12-exercise/5692/1 "2021-06-24T12:50:16Z")

</div>

```auto
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?

---

<div class="post-metadata">

**Author:** ![Kalo](https://avatars.discourse-cdn.com/v4/letter/k/6bbea6/32.png) [@Kalo](https://forum.codewithmosh.com/u/Kalo)\
**Post date:** [June 28, 2021, 3:29pm UTC](https://forum.codewithmosh.com/t/python-4-12-exercise/5692/3 "2021-06-28T15:29:22Z")

</div>

Hi,  
My solution:

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

```
