.capitalize()

Anonymous contributor's avatar
Anonymous contributor
Anonymous contributor's avatar
Anonymous contributor
Published May 10, 2021Updated Sep 22, 2023
Contribute to Docs

The .capitalize() method takes in a string, and returns a copy of the string with the first character in upper case, and the remaining characters in lower case.

Syntax

"string".capitalize()
  • This method does not have any parameters.
  • It does not modify the original string, it returns a copy of the string with the applicable case changes.

Example

The following example applies .capitalize() to a string in which all the characters are uppercase:

print("WELCOME TO CODECADEMY DOCS!".capitalize())

This will result in:

Welcome to codecademy docs!

Codebyte Example

The following example is runnable and uses the .capitalize() method:

us
Visit us
code
Hide code
Code
Output
Hide output
Hide output
Loading...

All contributors

Looking to contribute?

Learn Python on Codecademy