Home »
Python
Python String | capitalize() Method with Example
Python string | capitalize() Method with Example, it is an in-built method in Python and it is used to return capitalized string.
Submitted by IncludeHelp, on July 18, 2018
capitalize() is an in-built method in Python, it returns the string in Capitalized case, in which first character of the sentence is in uppercase and rest of the characters are in lowercase.
Syntax:
String.capitalize()
Parameter: None
Return type: It returns capitalize case string.
Example:
# str1
str1 = "Hello world, how are you?"
print str1.capitalize ()
# str2
str2 = "HELLO WORLD, HOW ARE YOU?"
print str2.capitalize ()
# str3
str3 = "hello world, how are you?"
print str3.capitalize ()
#str4
str4 = "100google is a website"
print str4.capitalize ()
Output
Hello world, how are you?
Hello world, how are you?
Hello world, how are you?
100google is a website