fizzbuzz answer python code example
Example 1: fizz buzz python
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"
else:
return input
print(fizz_buzz(3))
Example 2: fizzbuzz in python
def fizzBuzz(size):
for i in range(size - (size -1), size + 1):
localResult = "fizz" if not i % 3 else ""
localResult = localResult + "buzz" if not i % 5 else localResult
localResult = str(i) if localResult == "" else localResult
print(localResult)