FizzBuzz program in Python

In this post, we will see how to program FizzBuzz in Python.

As per wikipedia,
Fizz buzz is a group word game for children to teach them about division.

Here are the rules of the game:

  • First player starts the game by saying number 1.
  • Next player says next number but fun part is
    • If number is divisible by 3, then player need to say Fizz
    • If number is divisible by 5, then player need to say Buzz
    • If number is divisible by 3 and 5 both, then player need to say FizzBuzz

For example:

If there are 20 children then number will be printed as below:

1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz 16 17 Fizz 19 Buzz

Simple FizzBuzz Python solution

Here is simple FizzBuzz Python solution

Output of above program will be:

FizzBuzz number are:
[‘1’, ‘2’, ‘Fizz’, ‘4’, ‘Buzz’, ‘Fizz’, ‘7’, ‘8’, ‘Fizz’, ‘Buzz’, ’11’, ‘Fizz’, ’13’, ’14’, ‘FizzBuzz’, ’16’, ’17’, ‘Fizz’, ’19’, ‘Buzz’]

That’s all about FizzBuzz program in Python.

Was this post helpful?

Leave a Reply

Your email address will not be published. Required fields are marked *