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

Creating a simple Ethereum Smart Contract in Golang

Information Architecture — e$aver app

How to prepare perfect GIFs for Dribbble in seconds

A Suggestion on Managing Data Changes in Spring Boot Using Flyway

Registering a Domain with AWS Route 53 & Creating a DynamoDB Table

Announcing our contributions to the BalticLSC project: Computing power supply supporting…

Interfaces

Northsec CTF Writeup: Failing revenge

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 — How To Split String Based on Multiple Delimiters

Python sigma rule #1

Python for loop