LeetCode: Fizz Buzz

Written by Stephanie Segura | April 25, 2021

Stephanie Segura
2 min readApr 25, 2021

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.,

--

--