このエラーはなぜ発生しますか?このエラーを解決するには、13文字シフトするための暗号を使用します。
トレースバック(最新の呼び出しの最後): はIndexErrorで ファイル "パイソン"、6行目、:範囲外の文字列インデックス
このコードに
Cipher = input("Enter encrypted text:")
length = len(Cipher)
start = 0
decrypt=""
while length!=Cipher:
asc=ord(Cipher[int(start)]) #String index out of range
if asc <=95:
decrypt=decrypt+Cipher[start]
elif asc >95 and asc <=110:
num = asc
num=num+13
decrypt=decrypt+chr(num)
elif asc>110 and asc<=122:
num = asc
num=num-13
decrypt=decrypt+chr(num)
else:
decrypt=decrypt+""
start=start+asc
print("DONE!")
どのように私はそれを解決するのですか?
を使用すると、5行目にあり何をしていますか?文字列の長さと文字列自体の比較それは意味をなさない – Basti