Learn Python 008: lists - a ridiculous user system

known_user = ['Alice', 'Betty', 'Charlie', 'Daniel', 'Edison']

while True:
    print('Hi, I am a ridiculous user system')
    name = input('Please enter your name: ').strip().capitalize()
    if name in known_user:
        print('Welcome, {}! It has been a while.'.format(name))
        leave = input('Would you like to be removed from the system? (y/n): ').strip().lower()
        if leave == 'y':
            known_user.remove(name)
            print('No worries, I will see you around.')
        elif leave == 'n':
            print('Great, I do not want you to leave anyway.')

#         what if the input is not y or n?

    else:
        print('You are not currently in the system.')
        join = input('Would you like to be added to the system? (y/n): ').strip().lower()
        if join == 'y':
            known_user.append(name)
            print('Nice to meet you, {}!'.format(name))
        elif join == 'n':
            print('No problem, hope to see you again.')

 

posted @ 2017-07-14 00:11  mxyzptlk  阅读(134)  评论(0)    收藏  举报