Python if else program to print Fizz-Buzz

In this python if else program, we will check whether the number id divided by the numbers are given in the question and print FIzz-Buzz according to it.

Steps to solve the program
  1. Take a number as input through the user.
  2. If a multiple of two print “Fizz” instead of the number and for the multiples of three print “Buzz”.
  3. For numbers that are multiples of both two and three print “FizzBuzz”.
  4. Use if-else statements for this purpose.
				
					num = int(input("Enter a number: "))

if num%2 == 0 and num%3 == 0:
    print("FizzBuzz")
elif num%2 == 0:
    print("Fizz")
elif num%3 == 0:
    print("Buzz")
				
			

Output :

				
					Enter a number: 6
FizzBuzz
				
			

Related Articles

check whether a given year is a leap or not.

check whether an alphabet is a vowel.

Leave a Comment