Split a message into multiple parts.
Messaging and social networking apps often require a message to be split into a number of smaller messages. For example, Twitter was once 140 characters per tweet, now called X, it is 280. SMS messages were typically 160 characters.
Write a program that asks the user to enter a message and the maximum number of characters allowed in a single message. The program then outputs a list of each part of the message up to the maximum number of characters for each part.
Use this boilerplate code as a starting point:
Remember to add a comment before a subprogram, selection or iteration statement to explain its purpose.
Enter the message: Hello
How many characters per message? :10
['Hello']
Enter the message: Hello, how are you today?
How many characters per message? :10
['Hello, how', ' are you t', 'oday?']
Use these resources as a reference to help you meet the success criteria.
Run the unit tests below to check that your program has met the success criteria.
Enter the message: The quick brown fox jumps over the lazy dog.
How many characters per message? :20
['The quick brown fox ', 'jumps over the lazy ', 'dog.']
Enter the message: The quick brown fox jumps over the lazy dog.
How many characters per message? :5
['The q', 'uick ', 'brown', ' fox ', 'jumps', ' over', ' the ', 'lazy ', 'dog.']
Enter the message: The quick brown fox jumps over the lazy dog.
How many characters per message? :26
['The quick brown fox jumps ', 'over the lazy dog.']
Enter the message: The quick brown fox jumps over the lazy dog.
How many characters per message? :44
['The quick brown fox jumps over the lazy dog.']
Check that you have: