On Fri, Jun 26, 2009 at 12:43 PM, powah<wong_po...@yahoo.ca> wrote: > How to change the first character of the line to uppercase in a text > file? > e.g. > 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"[2] --> "c") And here are the docs on working with files: http://docs.python.org/library/functions.html#open http://docs.python.org/library/stdtypes.html#file-objects That should be enough to get you started. Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list