#!/usr/bin/python3 #this script splits text on space with a maximum of 240 characters #but on whole words. because icy_medata has a max of 255 characters. import sys text = sys.stdin.readlines() output = [] line = [] sentence = "" for words in text: for word in words.split(): if len(word) + len(" ".join(line)) < 240: line.append(word) else: output.append(" ".join(line)) line = [] line.append(word) "#add the last word" output.append(" ".join(line)) for line in output: print(line.replace(',', ''))