In this python if else program, we will convert the month name to the number of days.
Steps to solve the program
- Take the month name as input through the user.
- 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
Python program to check whether a triangle is equilateral or not.
Python program to check whether a triangle is scalene or not.
Python program to check whether a triangle is isosceles or not.
Python program that reads month and returns season for that month.
Python program to check whether the input number is divisible by 12 or not.