Python FizzBuzz Solution
# fizz multiples of 3
# buzz multiples of 5
# fizzbuzz multiples of both
i = 1
for i in range(1,51):
if i % 3 == 0 and i % 5 == 0:
print("fizzbuzz")
elif i % 3 == 0:
print("fizz")
elif i % 5 == 0:
print("buzz")
else:
print(i)
i += 1
Why FizzBuzz
# buzz multiples of 5
# fizzbuzz multiples of both
i = 1
for i in range(1,51):
if i % 3 == 0 and i % 5 == 0:
print("fizzbuzz")
elif i % 3 == 0:
print("fizz")
elif i % 5 == 0:
print("buzz")
else:
print(i)
i += 1
Why FizzBuzz
Comments
Post a Comment