Câu 10: PCED-30-02: PCED - Certified Entry-Level Data Analyst with Python
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, andCapitalize the first letter of each word (e.g., convert "new york" to "New York"). For example:"New york " → "New…
Nội dung câu hỏi
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, andCapitalize 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.
Các lựa chọn
Đáp án được giữ gọn theo nhãn A, B, C, D trong phần bình chọn tương tác.
- A. cleaned_city = city.strip().capitalize()
- B. cleaned_city = city.upper().replace(" ", "")
- C. cleaned_city = city.upper().strip()
- D. cleaned_city = city.strip().title() — đáp án hiện tại
Cộng đồng
0 bình luận công khai. Tên thành viên được ẩn một phần.