我想做一个字符串加密的程序,我想用for循环设置加密次数,可是我用了for循环却不行,求解决方案 谢谢
a=input("请输入您要加密的英文:")
for q in range(2):#设置加密次数
for i in range(len(a)):
if (ord(a[i])>=65 and ord(a[i])<=87) or(ord(a[i])>=97 and ord(a[i])<=119):
m=chr(ord(a[i])+3)
elif (ord(a[i])>=88 and ord(a[i])<=90) or(ord(a[i])>=120 and ord(a[i])<=122):
m=chr(ord(a[i])-23)
else:
m=a[i]
print(m,end='')