dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
73 lines
1.5 KiB
Markdown
73 lines
1.5 KiB
Markdown
---
|
|
id: 691b559495c5cb5a37b9b486
|
|
title: "Challenge 126: Capitalize It"
|
|
challengeType: 29
|
|
dashedName: challenge-126
|
|
---
|
|
|
|
# --description--
|
|
|
|
Given a string title, return a new string formatted in title case using the following rules:
|
|
|
|
- Capitalize the first letter of each word.
|
|
- Make all other letters in each word lowercase.
|
|
- Words are always separated by a single space.
|
|
|
|
# --hints--
|
|
|
|
`title_case("hello world")` should return `"Hello World"`.
|
|
|
|
```js
|
|
({test: () => { runPython(`
|
|
from unittest import TestCase
|
|
TestCase().assertEqual(title_case("hello world"), "Hello World")`)
|
|
}})
|
|
```
|
|
|
|
`title_case("the quick brown fox")` should return `"The Quick Brown Fox"`.
|
|
|
|
```js
|
|
({test: () => { runPython(`
|
|
from unittest import TestCase
|
|
TestCase().assertEqual(title_case("the quick brown fox"), "The Quick Brown Fox")`)
|
|
}})
|
|
```
|
|
|
|
`title_case("JAVASCRIPT AND PYTHON")` should return `"Javascript And Python"`.
|
|
|
|
```js
|
|
({test: () => { runPython(`
|
|
from unittest import TestCase
|
|
TestCase().assertEqual(title_case("JAVASCRIPT AND PYTHON"), "Javascript And Python")`)
|
|
}})
|
|
```
|
|
|
|
`title_case("AvOcAdO tOAst fOr brEAkfAst")` should return `"Avocado Toast For Breakfast"`.
|
|
|
|
```js
|
|
({test: () => { runPython(`
|
|
from unittest import TestCase
|
|
TestCase().assertEqual(title_case("AvOcAdO tOAst fOr brEAkfAst"), "Avocado Toast For Breakfast")`)
|
|
}})
|
|
```
|
|
|
|
# --seed--
|
|
|
|
## --seed-contents--
|
|
|
|
```py
|
|
def title_case(title):
|
|
|
|
return title
|
|
```
|
|
|
|
# --solutions--
|
|
|
|
```py
|
|
def title_case(title):
|
|
return " ".join(
|
|
w[:1].upper() + w[1:].lower()
|
|
for w in title.split(" ")
|
|
)
|
|
```
|