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
This code will be run on Ubuntu.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started