# 为什么我的while循环只运行一次？

[英]Why does my while loop only run once?

``````a = 0
Let = input("Enter a sentence to decrypt : ")
Num = 0
b = 0
while b < 26 :
Num = Num + 1
num = int(Num)
while a < len(Let) :
if  ord(Let[a]) > 96 and ord(Let[a]) < 123 and ord(Let[a]) + Num > 96 and ord(Let[a]) + Num < 123 :
print(chr(ord(Let[a]) + Num))
elif ord(Let[a]) > 64 and ord(Let[a]) < 91 and ord(Let[a]) + Num > 64 and ord(Let[a]) + Num < 91 :
print(chr(ord(Let[a]) + Num))
elif ord(Let[a]) > 96 and ord(Let[a]) < 123 and ord(Let[a]) + Num >= 123 :
while ord(Let[a]) + num >= 123 :
num = Num - 26
print(chr(ord(Let[a]) + num))
elif ord(Let[a]) > 64 and ord(Let[a]) < 91 and ord(Let[a]) + Num >= 91 :
while ord(Let[a]) + num >= 91 :
num = Num - 26
print(chr(ord(Let[a]) + num))
a = a + 1
b = b + 1
``````

``````Let = input("Enter a sentence to decrypt : ")
Num = 0
b = 0
while b < 26 :
Num = Num + 1
num = int(Num)
a = 0
out = ""
while a < len(Let) :
if  ord(Let[a]) > 96 and ord(Let[a]) < 123 and ord(Let[a]) + Num > 96 and ord(Let[a]) + Num < 123 :
out += (chr(ord(Let[a]) + Num))
elif ord(Let[a]) > 64 and ord(Let[a]) < 91 and ord(Let[a]) + Num > 64 and ord(Let[a]) + Num < 91 :
out += (chr(ord(Let[a]) + Num))
elif ord(Let[a]) > 96 and ord(Let[a]) < 123 and ord(Let[a]) + Num >= 123 :
while ord(Let[a]) + num >= 123 :
num = Num - 26
out += (chr(ord(Let[a]) + num))
elif ord(Let[a]) > 64 and ord(Let[a]) < 91 and ord(Let[a]) + Num >= 91 :
while ord(Let[a]) + num >= 91 :
num = Num - 26
out += (chr(ord(Let[a]) + num))
a = a + 1
print(out)
b = b + 1
``````

``````Let = input("Enter a sentence to decrypt : ")
Num = 0
b = 0
while b < 26 :
Num = Num + 1
num = int(Num)
out = ""
for a in Let:
if  ord(a) > 96 and ord(a) < 123 and ord(a) + Num > 96 and ord(a) + Num < 123 :
out += (chr(ord(a) + Num))
elif ord(a) > 64 and ord(a) < 91 and ord(a) + Num > 64 and ord(a) + Num < 91 :
out += (chr(ord(a) + Num))
elif ord(a) > 96 and ord(a) < 123 and ord(a) + Num >= 123 :
while ord(a) + num >= 123 :
num = Num - 26
out += (chr(ord(a) + num))
elif ord(a) > 64 and ord(a) < 91 and ord(a) + Num >= 91 :
while ord(a) + num >= 91 :
num = Num - 26
out += (chr(ord(a) + num))
print(out)
b += 1
``````