python自学项目day3.条件控制 if...else 给用

2017-11-07  本文已影响5人  Clemente

用一句话概括 if...else 结构的作用:如果...的条件是成立,就做...;反之,就做....

条件就指的是成立的条件,即是返回值为True的布尔(1)表达式。

password_list = ['*****','12345']
def account_login():
    password = input('Password:')
    password_correct = password == password_list[-1]
    password_reset = password == password_list[0]

    if password_correct:
        print('Login success!')
    elif password_reset:
        new_password = input('Enter a new password:')
        password_list.append(new_password)
        print('Your password has changed successfully!')
        account_login
    else:
        print('Wrong password or invalid input!')
        account_login()
account_login()
image.png
上一篇下一篇

猜你喜欢

热点阅读