Write a python program to input month number and print number of days in that month.

SOLUTION....

# Program to print number of days in a month (Python version)

# Input month number
month = int(input("Enter month number (1-12): "))

if month == 1:
    print("31 days")
elif month == 2:
    print("28 or 29 days")
elif month == 3:
    print("31 days")
elif month == 4:
    print("30 days")
elif month == 5:
    print("31 days")
elif month == 6:
    print("30 days")
elif month == 7:
    print("31 days")
elif month == 8:
    print("31 days")
elif month == 9:
    print("30 days")
elif month == 10:
    print("31 days")
elif month == 11:
    print("30 days")
elif month == 12:
    print("31 days")
else:
    print("Invalid input! Please enter month number between (1-12).")

OUTPUT

Leave a Reply

Your email address will not be published. Required fields are marked *

sign up!

We’ll send you the hottest deals straight to your inbox so you’re always in on the best-kept software secrets.