Python 3 Script to Capitalize First and Last Letters or Characters of Each Word in Text File
line = result = line.title()
result = ""
for word in line.split():
result += word[:-1] + word[-1].upper() + " "
print(capitalize_first_last_letters("python exercises practice solution"))
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
output+=capitalize_first_last_letters(line.title()) + "n"
# This will print the output
f = open("output.txt","w")