Capitalizes first character of the string
Usage
The capitalize()
method returns a copy of the string with its first character capitalized and the rest lowercased.
The method does not change the original string.
Syntax
string.capitalize()
Basic Example
# Capitalize the string
S = 'bob is a CEO at ABC.'
x = S.capitalize()
print(x)
# Prints Bob is a ceo at abc.
Non-alphabetic First Character
For the string with non-alphabetic first character, the first character is kept unchanged while the rest is changed to lowercase.
S = '42 is my FAVOURITE number.'
x = S.capitalize()
print(x)
# Prints 42 is my favourite number.