Answer:
#Welcome message
print("welcome to CheckMonth2")
#prompting day and month
day = int(input("Please, add a day: "))
month = int(input("please, add a month: "))
#Defining max number of days per each month
monthly_days = [31,29,31,30,31,30,31,31,30,31,30,31]
#Validating day and month were added properly
if month > 12 or month < 1:
print("invalid date for the month")
elif day > monthly_days[month-1] or day < 1:
#Printing error message
print("invalid date for the month")
else:
#printing correct message
print ("{}/{} is a valid birthday".format(day,month))
Step-by-step explanation:
This code was made using Python and consists of the following parts:
- A Welcome message with the name of the code.
- A line to prompt the day.
- A line to prompt the month.
- A list to define the number of day per month. For example, the first posistion of the list corrresponds to the maximum number of days in January, the next is for February and so on.
- A conditional tests to validate the day and month are in correct. ranges.
- Output the error message if conditions are not met.
- Output date if contidios are met.