python chunk text

Solutions on MaxInterview for python chunk text by the best coders in the world

showing results for - "python chunk text"
Martha
30 Apr 2016
1orig_string = “Well, Prince, so Genoa and Lucca are now just family estates of the Buonapartes. But I warn you, if you don’t tell me that this means war, if you still try to defend the infamies and horrors perpetrated by that Antichrist—I really believe he is Antichrist—I will have nothing more to do with you and you are no longer my friend, no longer my ‘faithful slave,’ as you call yourself! But how do you do? I see I have frightened you—sit down and tell me all the news.”
2list_of_lines = []
3max_length = 20
4while len(orig_string) > max_length:
5    line_length = orig_string[:max_length].rfind(' ')
6    list_of_lines.append(orig_string[:line_length])
7    orig_string = orig_string[line_length + 1:]
8list_of_lines.append(orig_string)
9
similar questions
queries leading to this page
python chunk text