Question: Write a Python code that asks users for their last name, validates it (i.e., checks it against business rules), and then displays it as confirmation
Write a Python code that asks users for their last name, validates it (i.e., checks it against business rules), and then displays it as confirmation with only the first letter capitalized, e.g., Smith. If the name is not valid per our business rules, the display should be Invalid Name instead.
The rules for last names at our business are:
Names must be no longer than 20 characters but must be at least two characters.
Names may have an apostrophe (e.g., ORourke) or a hyphen (e.g., SmithBarnes) but no other punctuation, no spaces, and no numbers.
For example, we dont allow Smith Jr. (has space and period) or Smith III (has space).
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
