Coding

Write code to implement a text wrapper that takes in a long string and a character limit as inputs and returns a list of strings, where each string is limited to the specified number of characters, split only at spaces. For example, if the input string is "This is a long sentence that needs to be wrapped", and the character limit is 10, the output should be a list with three strings: ["This is a", "long", "sentence that", "needs to be", "wrapped"].

Did you come across this question in an interview?

Interview question asked to Data Scientists interviewing at Zillow, Snap, Scribd and others: Write code to implement a text wrapper that takes in a long string and a character limit as inputs and returns a list of strings, where each string is limited to the specified number of characters, split only at spaces. For example, if the input string is "This is a long sentence that needs to be wrapped", and the character limit is 10, the output should be a list with three strings: ["This is a", "long", "sentence that", "needs to be", "wrapped"]..