Capitalize Every Word | Challenge

PythonPythonBeginner
Practice Now

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.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL python(("`Python`")) -.-> python/BasicConceptsGroup(["`Basic Concepts`"]) python(("`Python`")) -.-> python/FunctionsGroup(["`Functions`"]) python/BasicConceptsGroup -.-> python/comments("`Comments`") python/FunctionsGroup -.-> python/function_definition("`Function Definition`") subgraph Lab Skills python/comments -.-> lab-13063{{"`Capitalize Every Word | Challenge`"}} python/function_definition -.-> lab-13063{{"`Capitalize Every Word | Challenge`"}} end

Capitalize Every Word

Problem

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.

Example

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.

Other Python Tutorials you may like