Capitalize() In Python

Method Name:

capitalize

 

Method signature:

capitalize()

   

Method Overview:

  • The capitalize() method of python str class returns a copy of the python string object with the following modifications done:
    • The first character of the string is capitalized
    • All other characters of the string except the first character are made lower case.

Example:

# String with lower case and upper case letters

aliceQuote = "Curiouser And Curiouser!";

print(aliceQuote.capitalize())

 

# string with all lower case letters

aliceQuote = "begin at the beginning";

print(aliceQuote.capitalize())

 

Output:

Curiouser and curiouser!

Begin at the beginning

 


Copyright 2018 © pythontic.com