On Jul 26, 2:41 pm, "Francesco Pietra" <[EMAIL PROTECTED]> wrote: > How to insert letter "A" on each line (of a very long list of lines) > at position 22, i.e., one space after "LEU", leaving all other > characters at the same position as in the original example: > > ATOM 1 N LEU 1 146.615 40.494 103.776 1.00 73.04 1SG > 2 > > In all lines"ATOM" is constant as to both position and string, while > "LEU" is constant as to position only, i.e., "LEU" may be replaced by > three different uppercase letters. Therefore, the most direct > indication would be position 22. > > Should the script introduce blank lines, no problem. That I know how > to correct with a subsequent script. > > Thanks > chiendarret
If you want to leave the rest of the strings as-is (i.e. the letter A overwrites whatever on position 22), Peter's code need to be modified a little: line = line[:22] + " " + line[23:] -- http://mail.python.org/mailman/listinfo/python-list