JOIN
对于这个字符串检查器 - 如果小写字母中有至少一个大写字母,或者反之亦然,则将7添加到分数上,而不是小写中的每个大写,反之亦然。我怎样才能做到这一点?即使添加了这些代码,当我输入“HellO”时,得分为41而不是34
答案 0 :(得分:1)
一旦你更好地检测到大写,你可以简单地password = "HelloWorld"
score = 0
for letter in password:
if letter.isupper():
score += 7
break
print(score) # score = 7
退出循环。所以:
password = "HelloWorld"
found_upper_case = False
score = 0
for letter in password:
if not found_upper_case and letter.isupper():
score += 7
found_upper_case = True
# check for symbols or whatever
print(score) # score = 7
或者,设置一个标志:
onTouchListener