强口令检测,但口令正确后无法停止循环,哪位大神指点一下?(已解决)

题目:写一个函数,它使用正则表达式,确保传入的口令字符串是强口令。强口令的
定义是:长度不少于 8 个字符,同时包含大写和小写字符,至少有一位数字。你可
能需要用多个正则表达式来测试该字符串,以保证它的强度。
import re
t = [re.compile(r'.{8,}'),re.compile(r'[a-z]'),re.compile(r'[A-Z]'),re.compile(r'd')] 
while True:
    text = input('请输入强口令:')
    if t[0].search(text) and t[1].search(text) and t[2].search(text) and t[3].search(text):
        print('口令正确')
        break
    else:
        print('口令错误,请重新输入:')
 
    
原文地址:https://www.cnblogs.com/huzhikai001/p/12821516.html