change the first character of the line to uppercase in a text file
clp2 at rebertia.com
Fri Jun 26 22:51:36 CEST 2009
On Fri, Jun 26, 2009 at 12:43 PM, powah<wong_powah at yahoo.ca> wrote:
> How to change the first character of the line to uppercase in a text
> input is:
> abc xyz
> Bd ef
> gH ij
> output should be:
> Abc xyz
> Bd ef
> GH ij
We're not in the business of doing homework. Some hints though:
`s.upper()` converts the string in variable `s` to all upper case
(e.g. "aBcD".upper() --> "ABCD")
`for line in afile:` iterates over each line in a file object. `afile`
is the file object and `line` gets assigned each line in turn.
`s[x]` gets you the (x+1)-th character in the string `s` (e.g.
"abcd" --> "c")
And here are the docs on working with files:
That should be enough to get you started.
More information about the Python-list