题中(4)coutinue不会使用,导致输出结果与要求不符合,求帮助修改~
s=input()
n=len(s)
if n<6:
print("密码长度不足6位")
else:
for i in "s":
if "a"<=s<="z":
print("密码格式正确")
else:
print("密码格式错误")
题中(4)coutinue不会使用,导致输出结果与要求不符合,求帮助修改~
s=input()
n=len(s)
if n<6:
print("密码长度不足6位")
else:
for i in "s":
if "a"<=s<="z":
print("密码格式正确")
else:
print("密码格式错误")
把判断密码字符串是否是字母那个for循环修改下即可。
修改如下:
s=input()
n=len(s)
pswGood=1 # 密码格式是否全是字母的标志,默认1为全是字母
if n<6:
print("密码长度不足6位")
else:
for i in s: # 遍历字符串s
# 如果是是字母,则继续判断下一个字符
if (i>='a' and i <='z') or (i>='A' and i<='Z'):
continue
else: # 如果不是字母,则打印提示信息,并退出循环
pswGood=0 # 把标志置0,表示当前密码不全是字母
print("密码格式错误")
break
if pswGood ==1: # 如果判断完整个字符串,都是字母,则打印正确提示信息
print("密码格式正确")