本題要求編寫程序,將給定字符串中的大寫英文字母按以下對應規則替換:
原字母 | 對應字母 |
---|---|
A | Z |
B | Y |
C | X |
D | W |
… | … |
X | C |
Y | B |
Z | A |
輸入格式:
輸入在一行中給出一個不超過80個字符、並以回車結束的字符串。
輸出格式:
輸出在一行中給出替換完成后的字符串。
輸入樣例:
Only the 11 CAPItaL LeTtERS are replaced.
輸出樣例:
Lnly the 11 XZKRtaO OeGtVIH are replaced.
1 # 字符串替換 2 # Author: cnRick 3 # Time : 2020-3-25 4 aStr_list = list(input()) 5 for i in range(len(aStr_list)): 6 if('A' <= aStr_list[i] <= 'Z'): 7 aStr_list[i] = str(chr(ord('Z') - (ord(aStr_list[i]) - ord('A')))) 8 print("".join(aStr_list))