Editor

Capitalize Words

#7 · Strings · Beginner · 35 XP · about 3 min

Write a function called capitalize_words(s) that capitalizes the first letter of each word in a string.

Example

capitalize_words("hello world")       # Returns "Hello World"
capitalize_words("python is fun")     # Returns "Python Is Fun"
capitalize_words("THE QUICK BROWN")   # Returns "The Quick Brown"

Requirements

  • Capitalize the first letter of each word
  • Convert all other letters to lowercase
  • Words are separated by spaces

Fastest solvers

Leaderboard

First solves only, ranked by stars and then time.