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)

Flatiron student, word nerd and otter enthusiast

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

5 Easy Tricks to Kickstart Your DevOps Transformation

When not to follow best practices: Abstractions

Dev Day 2: Version Control

When Python meets Paint: An intro to RPA with Python

Introduction to Pi-Pad Attenuators — The Engineering Knowledge

Decomposing FragmentLifecycleCallbacks

5 Key Considerations When Choosing Kubernetes

Weeknote: 9 July 2021

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
Crystal Villanueva

Crystal Villanueva

Flatiron student, word nerd and otter enthusiast

More from Medium

Python program to check Armstrong number.

Setting up your Data Science project

Learning Python Programming: Language Fundamentals-I

Python: Arithmetic operations