-1
以下のコードを修正することができず、何らかの理由でコードが実行されていません。あなたはのでそのあなたのコード全体の変数と矛盾しているから別にPythonで 'Encrypt message'を作成する際のコードの脆弱性
message = input ('Enter your message')
key = int (input('How many Characters should we shift(between 1 - 26)- '))
secret-message = ""
for char in message:
if char.isalpha():
#Get the character code and add the shift amount
char_code = ord(char)
chat_code += key
#if upper case then compare to uppercase unicode
if char.isupper():
#if upper than Z substract 26
if char_code > ord('Z'):
char_code -= 26
#if smaller than A add 26
if char_code < ord('A'):
char_cod += 26
#Do the same for lower character
else:
if char_code > ord('z'):
char_code -= 26
if char_code < ord('a'):
char_cod += 26
#Convert From Code to letter and add to message
secret-message = secret-message + chr(char_code)
else:
secret-message = secret-message + char
print (" Encripted :" , secret-message)
あなたは変数に矛盾しています: 'char_code'、' chat_code'、 'char_cod' – srig