Invitation to Computer Science 8th Edition

Published by Cengage Learning
ISBN 10: 1337561916
ISBN 13: 978-1-33756-191-4

Chapter 9 - Challenge Work - Page 477: 2b

Answer

See explanation

Work Step by Step

In the below code WriteMessage function is created to write the message in main function. def WriteMessage(data): $\quad$ n=len(data) $\quad$ print("The message is: ",end="") $\quad$ for i in range(n): $\quad$ $\quad$ print(data[i],end="") def main(): $\quad$ print("Please enter at max 10 characters, one character per line. Use % to end the message") $\quad$ data=[] $\quad$ while(True): $\quad$ $\quad$ char=input() $\quad$ $\quad$ if char == "%": $\quad$ $\quad$ $\quad$ break $\quad$ $\quad$ else: $\quad$ $\quad$ $\quad$ data.append(char) $\quad$ WriteMessage(data) main()
Update this answer!

You can help us out by revising, improving and updating this answer.

Update this answer

After you claim an answer you’ll have 24 hours to send in a draft. An editor will review the submission and either publish your submission or provide feedback.