Python Program - Capitalize the First Character of a String

‮gi.www‬iftidea.com

here's a Python program that capitalizes the first character of a string:

# get input from user
s = input("Enter a string: ")

# capitalize the first character
new_s = s[0].upper() + s[1:]

# print the new string
print("Original string:", s)
print("New string:", new_s)

In this program, we first get input from the user using the input() function, and store it in the variable s.

We then use string slicing to extract the first character of the string (s[0]), and use the upper() method to convert it to uppercase. We concatenate this uppercase first character with the rest of the string (s[1:]), which we leave unchanged.

Finally, we print out the original string and the new string using the print() function.