Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/306.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python密码,三次尝试_Python - Fatal编程技术网

Python密码,三次尝试

Python密码,三次尝试,python,Python,我只是创建了一个密码验证过程。程序要求用户输入密码;他们有三次尝试。如果他们没有纠正,请让他们再试一次。它只是不能正常运行 如果我输入Tom作为密码,它将不会被授予访问权限。此外,在我尝试了两次尝试后,第三次尝试没有出现 password = 'Tom' count = 0 while count <= 3: Question = input('Please enter the password: try1') if Question == password:

我只是创建了一个密码验证过程。程序要求用户输入密码;他们有三次尝试。如果他们没有纠正,请让他们再试一次。它只是不能正常运行

如果我输入Tom作为密码,它将不会被授予访问权限。此外,在我尝试了两次尝试后,第三次尝试没有出现

password = 'Tom'
count = 0
while count <= 3:
     Question = input('Please enter the password: try1')
     if Question == password:
       print('Access granted Pass 1')
       break
     while count <= 2:
         Question = input('That is incorrect, please try again: trytwo')
         count += 2
     while count <= 1 :
        Question = input('That is incorrect, please try again: trythree')

     else:
        print('Access denied')
        count += 1

在这种情况下,您不正确地使用while循环

密码='Tom' 计数=1 而计数