私は非常に基本的な暗号化プログラムを作成しました。そのための復号化アルゴリズムを作成しているときに、ループでいくつかの問題に遭遇しました。
from re import *
cipher = open('cipher.txt')
ciphertext = cipher.read()
keyfile = open('key.txt')
key = keyfile.read()
decoded = []
chardec = ''
inval = 1
print("Decoder for encrypt1.py")
while inval == 1:
useManKey = input("Use a manual key? Y or N\n> ")
if useManKey == 'Y' or 'y':
key = input("Please enter the key you wish to use to decrypt\n> ")
inval = 0
elif useManKey == 'N' or 'n':
inval = 0
print("OK, decrypting")
else:
print("That wasn't a valid option/nPlease re-enter")
これを実行し、useManKey を N または n として宣言すると、Y または y として宣言したかのように、ループの if 部分が実行されるようです。私はおそらくここでばかげていますが、どんな助けでも大歓迎です。