```python= # 密文內容 message = input('Enter contents: ') # 轉換小寫字母 message = message.lower() # 偏移量 shift = 1 # 土法煉鋼字母表 alphabet = 'abcdefghijklmnopqrstuvwxyz' # 空白字串 result = '' # 詳細寫法 for character in message: if character in alphabet: # 檢查是否為英文字母 position = alphabet.index(character) # 尋找字母位置 new_position = (position - shift) % 26 # 設定新位置 result += alphabet[new_position] # 添加新字母 # result += alphabet[(alphabet.index(character) - shift) % 26] # 上三行整合成一行 else: # 英文字母以外,如標點符號及空格 result += character print(result) # 利用 Generator Expression 整合所有 for loop, if, else, 再用 join 連接字符串 # 排版為求閱讀方便,其實這裡只有一行 print( ''.join( alphabet[(alphabet.index(character) - shift) % 26] if character in alphabet else character for character in message) ) ```