[EMAIL PROTECTED] wrote: > I am trying to work out how to make it find a string like this "===" > and when it has found it, I want it to add "===" to the end of the > line.
how about if line.startswith("==="): line = line + "===" or if "===" in line: # anywhere line = line + "===" ? > if line.rfind("--------------------") is not -1: > new = line.replace("--------------------","----") it's not an error to use replace on a string that doesn't contain the pattern, so that rfind is rather unnecessary. (and for cases where you need to look first, searching from the left is usually faster than searching backwards; use "pattern in line" or "line.find(pattern)" instead of rfind. </F> -- http://mail.python.org/mailman/listinfo/python-list