LeetCode: Fizz Buzz

Thank you for visiting this post! Be sure to also take a look at my other work on LinkedIn, Github, and my website.

Presenting an Algorithm you know and love; Please welcome the myth, the legend, the one and ONLY…FizzBuzz.

I’ve solved this problem before in JavaScript, but I have NEVER solved this using Python, which I’m in the process of learning.

Im going to show you both my solutions for this problem using JavaScript and Python. Let’s see how they compare with one another!

Problem

Please click the link below to view the Problem Statement

Solution

Above is my first JS solution for FizzBuzz. Let’s see how it compares to my Python Solution below.

Both solutions for Javascript and Python use a for loop and conditional statements. The syntax is a but different, but they essentially do the same thing.

The range() function returns a sequence of numbers, starting from 0 by default, and increments by 1 (by default), and ends at a specified number.

— W3 Schools

Rather than use else if like Javascript, Python uses elif. Both do the same thing!

Also, Python does not recognize ‘===’ like JavaScript does, but rather it uses ‘==’ only.

Conclusion

All in all, I had a lot of fun solving this. The more I progress in my learning of Python, the more I hope to write about the language.

Thank you so much for stopping by! Stay tuned for more Algorithm Content!

Please checkout my online portfolio and feel free to connect with me on Linkedin!

Sources:

https://www.w3schools.com/python/python_for_loops.asp#:~:text=The%20range()%20function%20returns,ends%20at%20a%20specified%20number.,

--

--

--

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

Recommended from Medium

What are Time and Space Complexity in Data Structure?

How to build fast on-demand video streaming using Alibaba ApsaraVideo VOD

Scraping S&P 500 index and extracting stock market data from Yahoo Finance API

🐔 Grillchicken : get daily rewards

Want to learn how to code? Start here.

Abstract Classes and OOP extras

Day 22–101 Days of DevOps — Introduction to AWS Lambda

Room monitoring and controlling system with ESP32, BME280, and Web Server

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
Stephanie Segura

Stephanie Segura

More from Medium

Count Good Meals

How to print all unique subsets of a set, using recursion and bit-manipulation.

leetcode practice — 2. Add Two Numbers

Leetcode 1209 Remove All Adjacent Duplicates in String II