FizzBuzz in Python

  1. Create your empty list.
  2. Use the range function and combine it with a for loop.
  3. Create conditional logic that states if the number is divisible by 3, 5 or 15, push “Fizz”, “Buzz” or “FizzBuzz” into the list. Else if the current iteration is not divisible by any of the numbers listed, push the number into the list.
  4. Return the list.
list = []for num in range(1,100):

if num % 3 == 0 and num % 5 == 0:
list.append(“FizzBuzz”)
elif num % 3 == 0:
list.append(“Fizz”)
elif num % 5 == 0:
list.append(“Buzz”)
else:
list.append(num)
print(list)

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store