Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

# 6 - getSecretMessage ( s , key ) - 1 0 pts Can attempt after String Indexing, Slicing, and Looping lecture You can hide

#6- getSecretMessage(s, key)-10pts
Can attempt after String Indexing, Slicing, and Looping lecture
You can hide a secret message in a piece of text by setting a specific character as a key. Place the key before every letter in the message, then fill in extra (non-key) letters between key-letter pairs to hide the message in noise.
For example, to hide the message "computer" with the key "q", you would start with "computer", turn it into "qcqoqmqpquqtqeqr", and then add extra letters as noise, perhaps resulting in "orupqcrzypqomqmhcyqpwhhqutqtxtqeyeqrpa". To get the original message back out, copy every letter that occurs directly after the key, ignoring the rest.
Write a function getSecretMessage(s, key) that takes a piece of text holding a secret message and the key to that message and returns the secret message itself. For example, if we called the function on the long string above and "q", it would return "computer". You are guaranteed that the key does not occur in the secret message.
Hint: loop over every character in the string. If the character you're on is the key, add the next character in the string to a result string.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

ISBN: 133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions

Question

Were all members comfortable brainstorming in front of each other?

Answered: 1 week ago

Question

5. What information would the team members need?

Answered: 1 week ago