Question: PYTHON 2. The mirror of the string vow is the string wov and the mirror image of wood is boow. The mirror of the string

PYTHON

2. The mirror of the string vow is the string wov and the mirror image of wood is boow. The mirror of the string bed cannot be represented by a string because the letter e does not have a mirror in the alphabet. Write a function mirror() that takes a string and, if it has a mirror, returns its mirror image. If it does not have a mirror, return the string INVALID. Hint: use a dictionary with the mirrors in it. You can see how to mirror letters by looking at the last example below: >>> mirror('vow') 'wov' >>> mirror('wood') 'boow' >>> mirror('bed') 'INVALID' >>> mirror('pout') 'tuoq' >>> mirror( mirror('pout') ) 'pout' >>> [(c,mirror(c)) for c in 'abcdefghijklmnopqrstuvwxyz'] [('a', 'INVALID'), ('b', 'd'), ('c', 'INVALID'), ('d', 'b'), ('e', 'INVALID'), ('f', 'INVALID'), ('g', 'INVALID'), ('h', 'INVALID'), ('i', 'i'), ('j', 'INVALID'), ('k', 'INVALID'), ('l', 'l'), ('m', 'm'), ('n', 'n'), ('o', 'o'), ('p', 'q'), ('q', 'p'), ('r', 'INVALID'), ('s', 'INVALID'), ('t', 't'), ('u', 'u'), ('v', 'v'), ('w', 'w'), ('x', 'x'), ('y', 'INVALID'), ('z', 'INVALID')]

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!