String Capitalize in Python

Level 245 keystrokes

This capitalizes the first character of a string. The capitalize() method makes the first letter uppercase.

Python code

# Create a lowercase string
1text = "hello world"
# capitalize() returns a new string with the first character uppercase and the rest lowercase
# Only the very first letter changes, so it prints Hello world (not Hello World)
2print(text.capitalize())

Output

Hello world
Practice typing this code

Practice typing this code. Results are not recorded in the rankings.

Symbols in this code

The symbols you type in this Python code and how often they appear.

  • "× 2
  • (× 2
  • )× 2
  • .× 1
  • =× 1

More Python examples at level 2

← Python typing practice