I am trying to change the first character of each word in a list to upper case using Python 2.7. I am able to change the entire list to lower case, but I am not getting what I want - i.e the first character of each word to be upper case. Any help is appreciated.
Thank you
with open('c:\FLOUpper.txt', 'r') as infile,open('c:\FLOLower.txt', 'w') as outfile:
data = infile.readlines()
data = data.capitalize()
outfile.write(data)
When I use the above code, its throwing a "list" object has no attributes 'capitalize.'
with open('c:\FLOUpper.txt', 'r') as infile,open('c:\FLOLower.txt', 'w') as outfile:
data = infile.read()
data = data.capitalize()
outfile.write(data)
The above code changes the first character of the entire file to upper and all the rest to lower.