H4. Current date and time in Python?
The Below Python program will capitalize the first character of a string:
string = input("Enter a string: ") # Use the capitalize() method to capitalize the first character capitalized_string = string.capitalize() # Print the capitalized string print("Capitalized string:", capitalized_string)
This program first asks the user to enter a string. Then it uses the capitalize() method to capitalize the first character of the string.
The capitalize() method capitalizes the first character of the string and converts all other characters to lowercase. If the first character is already capitalized, the method doesn’t do anything.
Finally, the program prints the capitalized string using the print() function.