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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started