change the first character of the line to uppercase in a text file

Peter Otten __peter__ at web.de
Sat Jun 27 13:56:46 EDT 2009


Terry Reedy wrote:

> Peter Otten wrote:
> 
>>>> Will your program handle empty lines of input correctly?
>>> Strangely enough, it seems to do so, but why?
>> 
>> Because there aren't any. When you read lines from a file there will
>> always be at least the newline character. Otherwise it would indeed fail:
> 
> Except possibly for the last line.

It may not end with a newline, but it will still contain at least one 
character.





More information about the Python-list mailing list