0 votes
in Python by
How can you capitalize the first letter of a string?

2 Answers

0 votes
by

We can use the capitalize() function to capitalize the first character of a string. If the first character is already in capital then it returns the original string.

Syntax: string_name.capitalize() ex: n = “greatlearning” print(n.capitalize())

o/p: Greatlearning

0 votes
by

In Python, you can use the capitalize() method to capitalize the first letter of a string. However, if a string already consists of a capital letter at the beginning, it will return the original string.

...