python - Splitting an SMS Reply -


While replying to an SMS, I have a limit of 160 characters. I currently have a code set (Which can be> 160) and it has been divided into several texts & lt; 160 It is also set so that the word is kept whole. I have included this:

  repl = 'The message may have to be sent & gt; 160 'texts = [] words = repl.split () curtext =' 'for words in words: # For the first word, leave the space if lane (kartect) == 0: doctrine + = word # check if current Message has been left in the elif lane (karate) & lt; = 155- (lane (word)) 1: doctrine + = '' + word # is not enough space Make a new message: texts.append (curtext) curtext = word curtext! = '': Texts.append (curtext) return policy  

However, now I want to modify it that it adds "Answer Me" for more at the end of each other message. Any thoughts about doing?

(I am writing code in Python)

  Answer = "Text will be sent ...." [=] [count = 0 current_text = [] in the answer.split () word for: if count + len (word) & lt; (160 if LAN (texts)% 2 == 0 others (160-17)): current_text.append (word) calculation + = (lane (word) + 1) Other: calculation = 0 if lane (texts)% 2! = 0): #Week-numbered text gets an additional message ... texts.append ("". Add (current_text) + "\ nMexa me for more") texts.append ("" .join ( Current_text)) current_text = []  

Comments