Python bootcamp · Lab 43

Title case

easyString Methods8 minLesson: String Methods

Read the question, write Python on the right, then Run or Check.

QuestionHint and solution stay closed until you open them

Read one line of words and print it in title case: the first letter of each word capitalised, the rest lowercase.

Python's str.title() does exactly this.

Input. One line of text.

Output. The same words, title-cased.

Examples

Example 1
Input
hello world
Output
Hello World
Example 2
Input
PYTHON labs
Output
Python Labs
Hint
  1. line.title() capitalises each word.
  2. strip() the line first so a stray newline does not linger.
Show correct code

Peek only after you have tried. You can still Check your own version.

print(input().strip().title())
main.pyPython · Ctrl + Enter runs
ResultIdle
Run to see output. Check grades the tests.