#312 · Strings · Intermediate · 70 XP · about 14 min
Write wrap(text, width) that breaks text into lines no longer than width characters and returns the lines as a list of strings.
width; otherwise start a new line with it.width goes on a line of its own.wrap('The quick brown fox jumps over the lazy dog', 10) # returns ['The quick', 'brown fox', 'jumps over', 'the lazy', 'dog'] wrap('a supercalifragilistic word', 8) # returns ['a', 'supercalifragilistic', 'word'] wrap('One two three.\n\nFour five.', 9) # returns ['One two', 'three.', '', 'Four', 'five.']
1 <= width <= 200text has at most 100,000 characters, and its only whitespace characters are spaces and \n.First solves only, ranked by stars and then time.