.capitalize()
christian.dinh2476 total contributions
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:
All contributors
- christian.dinh2476 total contributions
- anli210 total contributions
- Anonymous contributorAnonymous contributor3071 total contributions
- Anonymous contributorAnonymous contributor186 total contributions
- CaupolicanDiaz142 total contributions
- christian.dinh
- anli2
- Anonymous contributor
- Anonymous contributor
- CaupolicanDiaz
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.