Question: Objective: Practice programming with dictionaries, strings, loops, and functions. You are given a dictionary crypt of type [String:String] which has values for all lowercase letters.

Objective:Practice programming with dictionaries, strings, loops, and functions.

You are given a dictionarycryptof type[String:String]which has values for all lowercase letters. Thecryptdictionary represents a way to encode a message. For example, ifcrypt["h"] = "@"andcrypt["i"] = "!"the encoded version of the message"hi"will be"@!".

Part 1:Write code that would take any string containing only lower case letters and spaces and encode it using thecryptdictionary (non-lower case letters can be encoded into themselves).

Use the followingcryptdictionary to test your code with the string message "hello swift":

================= varcrypt = [ "a" : "$", "b" : "&", "c" : "", "d" : "*", "e" : "%", "f" : "", "g" : ")", "h" : "@", "i" : "!", "j" : ">", "k" : "<", "l" : "{", "m" : "}", "n" : "?", "o" : "/", "p" : "", "q" : "-", "r" : "", "s" : "~", "t" : "", "u" : ".", "v" : "[", "w" : "]", "x" : "|", "y" : ":", "z" : "_", " ": "" ]

Sample input:crypto swift

Expected Output::/~]!

Part 2:Write a function that takes a string and returns its encoded version using the crypt dictionary. Test your function with few samplestrings including the sample input above.

Deliverables:Submit (1) a copy of your code for Part 2 (be sure to put your name and indicate which part of the assignment you completed), (2) screen shot of at least two test cases showing your solution meets problem specs above.

the first coding gave some build in errors.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!