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.
fname = "file.txt" with open(fname, 'r') as f: for line in f: l = line.title() print(l)
Do comment if you have any comments or suggestions on this Python capitalize program.
Note: IDE: PyCharm 2021.1.3 (Community Edition)
All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.
Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology & like learning technical.