def word_wrap(self, text, width=<NUM_LIT>):
substrings = []<EOL>string = text<EOL>while len(string) > width:<EOL><INDENT>index = width - <NUM_LIT:1><EOL>while not string[index].isspace():<EOL><INDENT>index = index - <NUM_LIT:1><EOL><DEDENT>line = string[<NUM_LIT:0>:index]<EOL>substrings.append(line)<EOL>string = string[index + <NUM_LIT:1>:]<EOL><DEDENT>substrings.append(string)<EOL>return substrings<EOL>
A simple word wrapping greedy algorithm that puts
as many words into a single string as possible.