Challenge: Name Normalizer
Swipe to start coding
Write a function that takes a string containing a person's name with inconsistent spacing and casing, and returns the name in a standardized format. The standardized format should have each word capitalized (first letter uppercase, remaining letters lowercase), with single spaces between words and no leading or trailing spaces.
- Remove any leading and trailing spaces from the input string.
- Convert the entire string to lowercase.
- Split the string into words, removing any extra spaces between words.
- Capitalize the first letter of each word and leave the remaining letters in lowercase.
- Join the words back together with a single space between each word.
Рішення
Дякуємо за ваш відгук!
single
Запитати АІ
Запитати АІ
Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат
Чудово!
Completion показник покращився до 4.76
Challenge: Name Normalizer
Свайпніть щоб показати меню
Swipe to start coding
Write a function that takes a string containing a person's name with inconsistent spacing and casing, and returns the name in a standardized format. The standardized format should have each word capitalized (first letter uppercase, remaining letters lowercase), with single spaces between words and no leading or trailing spaces.
- Remove any leading and trailing spaces from the input string.
- Convert the entire string to lowercase.
- Split the string into words, removing any extra spaces between words.
- Capitalize the first letter of each word and leave the remaining letters in lowercase.
- Join the words back together with a single space between each word.
Рішення
Дякуємо за ваш відгук!
single