python解决fizz buzz问题的最简解

def fizz_buzz(input):
    if input % 3 == 0 and input % 5 == 0:
        return "fizz buzz"
    if input % 3 == 0 :
        return "fizz"
    if input % 5 == 0:
        return "buzz"
    return input
print(fizz_buzz(1))
print(fizz_buzz(3))
print(fizz_buzz(5))
print(fizz_buzz(15))
1
fizz
buzz
fizz buzz

你可能感兴趣的:(python)