Python Forum
Split string into 160-character chunks while adding text to each part
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Split string into 160-character chunks while adding text to each part
#1
HELP!
A company has hired you as a consultant to develop software that can be used for sending SMS to their end-users. Currently, the maximum number of characters possible for one message is 160. Some of the messages the company sends contain more than 160 characters and need to be broken up into smaller chunks.

The company has expressed concerns that when sending messages in different chunks there is no guarantee that the messages will be delivered to the end-user’s phone in order. To circumvent this problem, the company would like to add pagination to the end of the message to give proper context to the end-user if needed.

As an example, the following message has 212 characters:
As a reminder, you have an appointment with Dr. Smith tomorrow at 3:30 pm. If you are unable to make this appointment, please call our customer service line at least 1 hour before your scheduled appointment time.

The message should be sent in two chunks as such:
As a reminder, you have an appointment with Dr. Smith tomorrow at 3:30 pm. If you are unable to make this appointment, please call our customer service (1/2)
and
line at least 1 hour before your scheduled appointment time. (2/2)

Your task is to develop a function that takes in a string message and returns an array of string messages with pagination if needed. For this exercise, the maximum number of characters in the input message is 1440. Also, do not break words into syllables and hyphens.
Reply


Messages In This Thread
Split string into 160-character chunks while adding text to each part - by iambobbiekings - Apr-30-2019, 06:15 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Reading a text until matched string and print it as a single line cananb 1 2,041 Nov-29-2020, 01:38 PM
Last Post: DPaul
  Replacing a few characters of a specified character but not all of them from a string fatherted99 7 3,263 Aug-13-2020, 09:08 AM
Last Post: fatherted99
  Appending to a text string syno7878 10 4,268 May-03-2020, 10:05 AM
Last Post: snippsat
  Using an integer to manipulate a string/text variable rexyboy2121 1 1,758 Apr-22-2020, 01:37 AM
Last Post: michael1789
  Adding string numbers, while loop and exit without input. Jose 11 7,530 Apr-15-2020, 08:34 AM
Last Post: Jose
  Trying to extract Only the capitol letters from a string of text Jaethan 2 2,188 Feb-27-2020, 11:19 PM
Last Post: Marbelous
  How to change part of the value string in Python Dictionary? sbabu 11 3,923 Feb-12-2020, 02:25 AM
Last Post: sbabu
  Tab character in a string prints 8 spaces hecresper 6 20,654 Aug-27-2019, 02:38 PM
Last Post: snippsat
  Split String lekuru01 6 3,522 Mar-19-2019, 10:42 AM
Last Post: lekuru01
  Finding and storing all string with character A at middle position Pippi 2 2,697 Jan-20-2019, 08:23 AM
Last Post: Pippi

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020