Mirror of character in string

You are given a string A of length N consisting of only lowercase english letters.
You need to generate B of length N which meets the following criteria

– Each element of B is a lowercase english letter
– Each element of B is opposite of A.
– For example - if A is azbyc, then B is zaybx
Input Format
The first line of input will contain a single integer T, denoting the number of test cases.
Each test case consists of a single line - the string A
Output Format
For each test case, output on a new line the string B

image

Solution: Python 3

t = int(input())
for i in range(t):
S = input()
A = “”
c = 0
i= 0
while i <len(S):
c = (abs(ord(S[i])-122))+97
A=A + chr(c)
i = i+1

print(A)
2 Likes