Capitalize First Letter In Words

Beginner

This tutorial is from open-source community. Access the source code

Introduction

In Python, we can capitalize the first letter of every word in a string using a built-in function. In this challenge, you will be asked to write a function that takes a string as an argument and returns a new string with the first letter of every word capitalized.

Capitalize Every Word

Write a function capitalize_every_word(s) that takes a string s as an argument and returns a new string with the first letter of every word capitalized.

def capitalize_every_word(s):
  return s.title()
capitalize_every_word('hello world!') ## 'Hello World!'

Summary

In this challenge, you have learned how to capitalize the first letter of every word in a string using a built-in function in Python. This skill can be useful in various applications, such as formatting text for display or processing user input.