QuestionQ14
VerifiedPython Basics for Data AnalysisYou are handling city names submitted by users. These names can include inconsistent capitalization and unwanted spaces.
To standardize the data, you need to:
- Remove any whitespace at the beginning or end, and
- Capitalize the first letter of every word (for example, change
"new york"to"New York").
For example:
"New york "→"New York""lOS ANGELES"→"Los Angeles"
You have a variable, city, that contains the raw input.
Which line of code correctly updates cleaned_city to perform the required transformation? Select the best answer.
Community Discussion