且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

我想防止两次打印

更新时间:2022-12-19 21:18:16

这是因为您两次运行该函数,一次在if语句中,一次在打印中.将其存储在这样的变量中:

This is because you are running the function twice, once in the if statement, and once in the print. Store it in a variable like so:

# ...

for i in range(0, 5):

    # ...
    # ...

    bibeon = input("Enter password: ")
    chkResult = passwordChk(bibeon)
    if chkResult == 'Valid Password':
        print(chkResult)
        break
    else:
        print(chkResult)