Python mirrored string function

前端 未结 5 497
攒了一身酷
攒了一身酷 2021-01-16 12:45

I\'m trying to develop a function mirror() that takes a string and returns its mirrored string but only if the mirrored string can be represented using \"mirror

5条回答
  •  被撕碎了的回忆
    2021-01-16 13:41

    You have the right idea about iterating through the given letters in reverse order. However, you cannot necessarily just give each letter itself as its own mirrored version. An example would be b and d, which are mirror versions of each other.

    The simplest way if you're learning to program would be to use a for loop to move backwards through the given letters, and use some if statements for each letter to determine the mirrored letter (if there is one).

提交回复
热议问题