Question 6
You are working with city names entered by users. These names may contain inconsistent capitalization and unwanted spaces. To standardize the data, you want to: Remove any leading or trailing whitespace, and Capitalize the first letter of each word (e.g., convert "new york" to "New York"). For example: "New york " → "New York" "lOS ANGELES" → "Los Angeles" You are given a variable city that contains the raw input. Which line of code correctly updates the value of cleaned_city to apply the required transformation? Select the best answer.
- cleaned_city = city.strip().capitalize()
- cleaned_city = city.upper().replace(" ", "")
- cleaned_city = city.upper().strip()
- cleaned_city = city.strip().title()