アルファベットの2文字ですべての文字を置き換える必要があります。例えば、g
~i
およびa
~c
である。私はここサブストリングが見つかりませんでした
substring not found
それを解決するためのプログラムを作っていた間、私はいつもこのエラーを取得する私のコードです:
string="g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq ypc dmp. bmgle gr gl zw fylb gq glcddgagclr ylb rfyr'q ufw rfgq rcvr gq qm jmle. sqgle qrpgle.kyicrpylq() gq pcamkkclbcb. lmu ynnjw ml rfc spj."
#=========this is the string on the site
alphapet="abcdefghijklmnopqrstuvwxyz"
#this is the alphapet ofcourse
x=""
y=0
z=""
m=0
#that was declaring variables
#the following is a loop which would go through string
for i in string:
#the if statement should check if i was in alphapet string
if i in alphapet:
if i=="y":
string.replace(i,"a")
elif i=="z":
string.replace(i,"b")
#the previous two conditions were special cases
else:
#the x will equal the first character as m =0 which is"g"
x=string[m]
#the y should equal the index of the character in alphapet this is were the error comes
y=alphapet.index(x)
#the z should equal the letter that comes after it by 2 in alphapet
z=alphapet[y+2]
#the following line should replace it
string.replace(i,z)
m+=1
print(string)
エラーの原因は何ですか? – nbryans
y = alphapet.index(x) – Ohumeronen
あなたの質問に含めるコードの中に 'substring not found 'という文字が表示されることはありません。 –