Write a Python program to convert month name to a number of days


Introduction

Write a Python program to convert month name to a number of days. I have used python 3.7 compiler for debugging purpose.


techstudy.org

HP 15 Core i3 7th gen Laptop(4GB, 1TB HDD, Windows 10) | Rs. 31,490

  1. print("List of months: January, February, March, April, May, June, July, August, September, October, November, December")
  2. month_name = input("Input the name of Month: ")
  3.  
  4. if month_name == "February":
  5. print("No. of days: 28/29 days")
  6. elif month_name in ("April", "June", "September", "November"):
  7. print("No. of days: 30 days")
  8. elif month_name in ("January", "March", "May", "July", "August", "October", "December"):
  9. print("No. of days: 31 day")
  10. else:
  11. print("Wrong month name")

Result

python language techstudy.org

     





Related Topics




Popular Posts