Welcome folks today in this post we will be
capitalize first letter of
every word in python. All the full source code of application is shown below.
In order to get started you need to make an
app.py file and copy paste the following code
# Python program to read a file and capitalize
# the first letter of every word in the file.
# A file named "gfg", will be opened with the
# reading mode.
file_gfg = open('file.txt', 'r')
# This will traverse through every line one by one
# in the file
for line in file_gfg:
# This will convert the content
# of that line with capitalized
# first letter of every word
# This will print the output
f = open("output.txt","w")
Now if you execute the above python script by typing the below command as shown below
So it will take the following
input text file and then process it and then create the
output text file as shown below