Convert the month name to the number of days.

In this python if else program, we will convert the month name to the number of days.

Steps to solve the program
  1. Take the month name as input through the user.
  2. Print the number of days according to the input month using if-else statements.
				
					month = input("Enter month: ").lower()

if month == "january":
    print("Number of days: 31")
elif month == "february":
    print("Number of days: 28/29")
elif month == "march":
    print("Number of days: 31")
elif month == "april":
    print("Number of days: 30")
elif month == "may":
    print("Number of days: 31")
elif month == "june":
    print("Number of days: 30")
elif month == "july":
    print("Number of days: 31")
elif month == "august":
    print("Number of days: 31")
elif month == "september":
    print("Number of days: 30")
elif month == "october":
    print("Number of days: 31")
elif month == "november":
    print("Number of days: 30")
elif month == "december":
    print("Number of days: 31")
else:
    print("Invalid month")
				
			

Output :

				
					Enter month: February
Number of days: 28/29
				
			

Related Articles

check whether an alphabet is a consonant.

check whether a triangle is equilateral or not.

Leave a Comment