My program is supposed to replace all sets of 4 spaces with a tab but it only seems to be editing the first line then skipping the rest of the lines. "work_string" is defined via another function which takes and saves an entire files input into one string. I just can't get my replacing function to act on multiple lines instead of just the first one.
Here's my replacing function, anyone have an idea of how to get it to act on every line of "work_string"?
def space_to_tab(work_string): s_to_tab = 4 whitespace = work_string[ : len(work_string) - len(work_string.lstrip())] whitespace = whitespace.replace(REAL_SPACE * s_to_tab, REAL_TAB) whitespace = whitespace.lstrip(REAL_SPACE) result = whitespace + (work_string.lstrip()) return result