Problem 163575 · medium · Phase 01 Prerequisites & Setup

Headline Check

strings · split · iteration · isupper · islower

An editor requires headlines in title case: every word starts with an uppercase letter and all its remaining letters are lowercase. Given headline, return True if it follows the rule and False otherwise. Words are separated by spaces. Words may contain digits or punctuation after the first character (for example Top-10 is fine); only the letters are checked. An empty headline has no words, so it counts as valid.

Examples

Input:  headline = "The Quick Brown Fox"
Output: True

Input:  headline = "The quick Brown Fox"
Output: False

Input:  headline = "NASA Launches Rocket"
Output: False

Constraints

  • 0 <= len(headline) <= 1000
  • headline may contain letters, digits, spaces and punctuation

Goals

  • Split a sentence into words
  • Inspect the first character and the rest of each word separately
  • Return False as soon as a word breaks the rule
Starting Python…