"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: >------------------------------- >whitespace = " " >old_indent = 3 >new_indent = 5 > >x = " starts with 3 spaces" > >x = x.replace(whitespace*old_indent, whitespace*new_indent) >------------------------------- > >In this example though, it will replace the 3 spaces no matter where >they are at, not just in the beginning... still, it's probably more >practical for most use cases.
You'd corner it with: if x.startswith(' '*3): x=x.replace(' '*3,' '*5,1) -- John Savage (my news address is not valid for email) -- http://mail.python.org/mailman/listinfo/python-list