I would like to read through a file and capitalize the first letters in a string using Python, but some of the strings may contain numbers first. Specifically the file might look like this:
"hello world"
"11hello world"
"66645world hello"
I would like this to be:
"Hello world"
"11Hello world"
"66645World hello"
I have tried the following, but this only capitalizes if the letter is in the first position.
with open('input.txt') as input, open("output.txt", "a") as output:
for line in input:
output.write(line[0:1].upper()+line[1:-1].lower()+"\n")
Any suggestions? :-)