Write a python program to convert month name to a number of days
In this post, you will learn how to convert a month name to a number of days using the Python programming language.
In the given example, we have used the if elif statement to convert the month name to a number of days.
month_name = input("Enter the name of Month: ")
if month_name == "February":
print("No. of days: 28/29 days")
elif month_name in ("April", "June", "September", "November"):
print("No. of days: 30 days")
elif month_name in ("January", "March", "May", "July", "August", "October", "December"):
print("No. of days: 31 day")
else:
print("Invalid month name")
Output of the above code:
Enter the name of Month: June
No. of days: 30 days
Enter the name of Month: April
No. of days: 30 days
Related Articles
Countdown clock and timer using Tkinter in PythonSimple Calculator Program in Python
Python gmplot to add google map on a web page
Python requests GET method
Python OpenCV ColorMap
Convert Python list to numpy array
Convert string to list Python
Python program to list even and odd numbers of a list
Python loop through list
Sort list in descending order Python
Convert array to list Python
Python take screenshot of specific window
Web scraping Python BeautifulSoup
Check if two strings are anagrams Python
Python program to add two numbers
Print new line python
Python for loop index
Convert List to Dataframe Python
numpy random choice
Dictionary inside list python
Check if list is empty Python
Python raise keyword
Python program to get the largest number from a list
Python program to map two lists into a dictionary