again = True
minimum = 8
errorcount = 0
digitm = 2
while again == True:
password = input('Enter a Password:')
passwords = len(password)
if passwords < minimum:
errorcount += 1
numblet = 0
numbdig = 0
blank = 0
numblower = 0
numbup = 0
for n in range(0, passwords):
if password(n).isalpha():
numblet += 1
if password(n).isdigit():
numbdig += 1
if password(n).isspace():
blank += 1
if password(n).islower():
numblower += 1
if password(n).isupper():
numbup += 1
我不明白为什么我的str对象是不可调用的,我正在尝试检查输入是否存在至少1个大写和小写字母,至少2位数字,无空格,以字母开头。
最佳答案
使用[]
而不是()
在Python中索引字符串。
again = True
minimum = 8
errorcount = 0
digitm = 2
while again == True:
password = input('Enter a Password:')
passwords = len(password)
if passwords < minimum:
errorcount += 1
numblet = 0
numbdig = 0
blank = 0
numblower = 0
numbup = 0
for n in range(0, passwords):
if password[n].isalpha():
numblet += 1
if password[n].isdigit():
numbdig += 1
if password[n].isspace():
blank += 1
if password[n].islower():
numblower += 1
if password[n].isupper():
numbup += 1
关于python - 如何调试“str对象不可调用”?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/53476496/