string capitalize() in Python

In Python, the capitalize() method converts the first character of a string to capital (uppercase) letter. If the string has its first character as capital, then it returns the original string.

Syntax:

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 capital.

Below is the python program to illustrate capitalize() function:

filter_none

edit
close

play_arrow

link
brightness_4
code

# Python program to demonstrate the 
# use of capitalize() function 
  
# capitalize() first letter of 
# string.
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())

chevron_right


Output:

Geeks for geeks
GeeksForGeeks


My Personal Notes arrow_drop_up

Striver(underscore)79 at Codechef and codeforces D

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

1


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.