Fizzbuzz -Algorithmus
def fizz_buzz(input):
if input % 3 == 0 and not input % 5 == 0:
return "Fizz"
if input % 5 == 0 and not input % 3 == 0:
return "Buzz"
if (input % 3 == 0) and (input % 5 == 0):
return "FizzBuzz"
return input
print(fizz_buzz(15))
# OR MORE SIMPLIFIED
def fizz_buzz(input):
if (input % 3 == 0) and (input % 5 == 0):
return "FizzBuzz"
if input % 3 == 0:
return "Fizz"
if input % 5 == 0:
return "Buzz"
return input
print(fizz_buzz(15))
OHIOLee