Advertisement
Sabev

User Logins

Jan 17th, 2019
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.57 KB | None | 0 0
  1. users = {}
  2. action = 'collect'
  3. unsuccessful = 0
  4.  
  5. while True:
  6.     inp = input()
  7.     if inp == 'login':
  8.         action = inp
  9.         continue
  10.     elif inp == 'end':
  11.         print(f'unsuccessful login attempts: {unsuccessful}')
  12.         break
  13.  
  14.     (username, password) = inp.split(' -> ')
  15.     if action == 'login':
  16.         if username in users and users[username] == password:
  17.             print(f'{username}: logged in successfully')
  18.         else:
  19.             print(f'{username}: login failed')
  20.             unsuccessful+=1
  21.  
  22.     else:
  23.         users[username] = password
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement