2
我創建了這個程序,如果它是對稱的,它應該顯示一個單詞的鏡像。不幸的是,當我測試「TIMOTHY」時,它顯示它不能被鏡像,我無法弄清楚爲什麼這不起作用。基於字母對稱創建鏡像字
#Program for creating a mirrored
#image word#
def main():
mirrors = ["A","H","I","M","O","T","U","V","W","X","Y"
"b","d","i","l","m","o","p","t","v","w","x"]
word = input("Enter in the word you'd like mirrored: ")
for x in word:
if x not in mirrors:
y = True
break
if y == True:
print("Sorry your word can not be mirrored")
wordlist = ''.join(word[i] for i in range(len(word) -1, -1, -1))
print(wordlist)
main()