1 '''从键盘录入密码,如果正确就结束循环''' 2 for item in range(3): 3 pwd = input('请输入密码') 4 if pwd == '8888': 5 print('密码正确') 6 break 7 else: 8 print('密码错误') 9 10 a = 0 11 while a < 3: 12 pwd = input('请输入密码') 13 if(pwd == '8888'): 14 print('密码正确') 15 break 16 else: 17 print('密码错误') 18 a += 1