Skip to content
Related Articles

Related Articles

Improve Article

string capitalize() in Python

  • Difficulty Level : Medium
  • Last Updated : 02 Dec, 2020

In Python, the capitalize() method returns a copy of the original string and converts the first character of the string to a capital (uppercase) letter while making all other characters in the string lowercase letters.
 

Syntax: 

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course

string_name.capitalize() 

string_name: It is the name of string of
             whose first character we want
             to capitalize.

Parameter: The capitalize() function does not takes any parameter. 
Return value: The capitalize() function returns a string with the first character in the capital. 
Below is the python program to illustrate capitalize() function: 
 

Python




# Python program to demonstrate the
# use of capitalize() function
 
# capitalize() first letter of string
# and make other letters lowercase
name = "geeks FOR geeks"
 
print(name.capitalize())
 
# demonstration of individual words
# capitalization to generate camel case
name1 = "geeks"
name2 = "for"
name3 = "geeks"
print(name1.capitalize() + name2.capitalize()
                         + name3.capitalize())

Output: 
 

Geeks for geeks
GeeksForGeeks

 

My Personal Notes arrow_drop_up
Recommended Articles
Page :