刚接触 Python 时,我需要制作这个循环吗?我知道它真的很杂乱



我如何进行这个循环,如果可能的话,我可以整理它?

l,a,b, = 0, 0, 0
password = str(input("Please enter a strong, 12 character password: "))
for i in password:
if password[0] or [1] or [2] or [3] or [4] or [5] or [6] or [7] or [8] or [9] or [10] or [11] or 
[12].islower():
l+=1
if password[0] or [1] or [2] or [3] or [4] or [5] or [6] or [7] or [8] or [9] or [10] or [11] or 
[12].isupper():
a+=1
if len(password) == 12:
b+=1
if l>=1 and a>=1 and b>=1:
print("valid password")
else:
print("invalid password")
  1. 清理程序代码:
l, a, b, = 0, 0, 0
password = str(input("Please enter a strong, 12 character password: "))
for i in password:
if i.islower():
l += 1
if i.isupper():
a += 1
if len(password) == 12:
b += 1
if l >= 1 and a >= 1 and b >= 1:
print("valid password")
else:
print("invalid password")
  1. 像"这样的非字母字符呢">

相关内容

  • 没有找到相关文章

最新更新