Question: Write a Python script named isValidTime.py that: a. Take 1 string as an argument and determine if it is a valid time in 12hour am/pm

Write a Python script named isValidTime.py that:

a. Take 1 string as an argument and determine if it is a valid time in 12hour am/pm

format.

b. Hour must be between 1 and 12 and can have 1 or 2 digits. Minutes must be between 0

and 59 and must have 2 digits. Example: 7:35 am and 09:59 pm are valid, while

7:65 am and 15:25 pm are not valid

c. The am/pm part is valid only if both characters are uppercase, or both characters are

lowercase. Example: AM, PM, am, and pm are all valid while aM, pM, Am,

Pm are not valid.

d. The space between the minute portion and am/pm portion is optional. Example:

7:35am and 7:35 am are both valid.

e. If valid print valid time, otherwise print invalid time

f. If there is not exactly 1 argument, print an error message and exit

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!