Created
November 11, 2019 11:46
-
-
Save russell310/5f56248995d9ad5f3bf7841e085457d6 to your computer and use it in GitHub Desktop.
Spliting long message into carrier recommended length
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def sms_spliter(msg_text): | |
| sms_lst=[] | |
| if len(msg_text) <= 160: | |
| sms_lst.append(msg_text) | |
| return sms_lst | |
| else: | |
| l_m_text = (msg_text.split()) | |
| if len(max(l_m_text, key=len))> 160: | |
| return sms_lst | |
| sms_string=l_m_text[0] | |
| for i in range(1,len(l_m_text)): | |
| if len(sms_string +' '+ l_m_text[i]) < 160 : | |
| sms_string=sms_string +' '+ l_m_text[i] | |
| else: | |
| sms_lst.append(sms_string) | |
| sms_string = l_m_text[i] | |
| sms_lst.append(sms_string) | |
| return sms_lst |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment