Rachel M.

asked • 02/20/23

Python string help(python 3)

I need help doing this for a function

Define a function named encrypt(msg) that takes a string message as the argument, and returns the message in an "encrypted" form using the encryption rules described below:

  1. If the character is an uppercase: change it to lowercase with '!' sign on its both sides (e.g. 'M' --> '!m!');
  2. If the character is a lowercase: change it to uppercase with '!' sign on its both sides (e.g. 'm' --> '!M!');
  3. If the character is a digit: cube the digit, i.e. raise to the power of 3 (e.g. '5' --> '125');
  4. If the character is a blank space: replace it with '$' symbol;
  5. Otherwise: keep it as it is.


1 Expert Answer

By:

Jonathan S. answered • 02/20/23

Tutor
5 (3)

Experienced Math Educator and Former Google Software Engineer

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.