Algorithm
1. Start
2. Input a string
3. Check if the string is not empty
a. If empty, print an error message and end
b. If not empty, proceed to the next step
4. Extract the first character of the string
5. Convert the first character to uppercase
6. Concatenate the uppercase first character with the rest of the string (excluding the first character)
7. Print the modified string
8. End
Code Examples
#1 Code Example- Pythom Programm Using list slicing
Code -
Python Programming
my_string = "DevsEnv is Lit"
print(my_string[0].upper() + my_string[1:])
Copy The Code &
Try With Live Editor
Output
#2 Code Example- Python program Using inbuilt method capitalize()
Code -
Python Programming
my_string = "DevsEnv is Lit"
cap_string = my_string.capitalize()
print(cap_string)
Copy The Code &
Try With Live Editor
Output
Demonstration
Python Programing Example to Capitalize the First Character of a String-DevsEnv