Files
wehub-resource-sync 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
chore: import upstream snapshot with attribution
2026-07-13 11:55:53 +08:00

1.5 KiB

id, title, challengeType, dashedName
id title challengeType dashedName
691b559495c5cb5a37b9b486 Challenge 126: Capitalize It 29 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".

({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".

({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".

({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".

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(title_case("AvOcAdO tOAst fOr brEAkfAst"), "Avocado Toast For Breakfast")`)
}})

--seed--

--seed-contents--

def title_case(title):

    return title

--solutions--

def title_case(title):
    return " ".join(
        w[:1].upper() + w[1:].lower()
        for w in title.split(" ")
    )