Python String capitalize() Method
Python capitalize() makes the first letter of a string uppercase and the other letters lowercase.
Python capitalize() Syntax
capitalize() method syntax.
str.capitalize()
Python capitalize() Parameters
- None.
Python capitalize() Return Value
This method returns an initial capitalized string.
Python capitalize() Example#1
The following example shows an instance of the capitalize() method.
#!/usr/bin/python3
str = "this is string Example From apidemos.com....great!!!"
print ("str.capitalize() : ", str.capitalize())
Output:
Python capitalize() Example#2
The Python String capitalize() method creates and returns a modified copy of the original string.
#!/usr/bin/python3
string = "apidemos.com - GOOD WEBSITE"
string_2 = string.capitalize()
print("New string after using capitalize():", string_2)
print("Original string:", string)
Output: