Write a program to capitalize first letter of every word in a file in Python

First, read each line from the file and then use the title() function to capitalize each word in the line. Example program to capitalize the first letter of every word in a file in Python Simple example code takes the content of the file as input and Prints it after altering it. Output: Inside File.txt Read More…


Python capitalize the first letter of a sentence | Example code

Use Python built-in capitalize() method to capitalize the first letter of a sentence and change the rest of the characters into lowercase. This method is used on string data in various ways without just capitalizing on the first characters. Example of capitalizing the first letter of every sentence in Python The capitalize() doesn’t take any Read More…


Python capitalize the first letter of every word in a string | Example code

Use title() to capitalize the first letter of every word in a string in python. Python Str class provides a member function title() which makes each word title cased in string. It converts the first character of each word to upper case and all remaining characters of the word to lower case. Example code capitalize Read More…


Write a python program to capitalize the first and last letters of each word of a given string

Example program to capitalize first and last letters of each word of a given string in Python. Output: Another Example Take input from the user and convert the first and last letter of string to Upper-Case in Python. First, do slicing the String convert 1st character and convert it to upper case and Concatenate the Read More…


Python capitalize the first letter without changing the rest | Example code

Just capitalize the first letter with str.upper() and concatenate the rest unchanged to capitalize the first letter without changing the rest in python. Python capitalize first letter only Example Python simple example code. Output: If the first character is an integer Output: 12Hello world Do comment if you have any doubts and suggestions on this Read More…


Python capitalize every other letter | Example code

Using for loop you can capitalize every other letter in Python programming. Iterate over the given string and capitalize car every other char with the if condition. Add both types of char into the new string. Example capitalise every other letter in a string in Python Simple python example code has a function to capitalize Read More…


Python capitalize the first letter of every word in the list | Example code

Use Python capitalize() method to capitalize every first letter of a word in the list. You have to also use for loop to iterate through the list. Example How tocapitalize the first letter of every word in the list Python simple code. Output: Another example You can also use the python string title method with Read More…