Capitalize the First Character of a String in Python Using capitalize()

(Last Updated On: 05/04/2023)

Python Program to Capitalize the First Character of a String Using capitalize() Function

#Capitalize the First Character of a String Using str.capitalize() in python

s = "python"
print("Original string: "+ s)

# string.capitalize () function takes the string argument and returns the first letter of the capitalized word
print("After capitalizing the first letter: "+ s.capitalize())

Output:

Original string: python
After capitalizing the first letter: Python

Leave a Reply

Your email address will not be published. Required fields are marked *