Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. n = int(input())
  2.  
  3. users = {}
  4. logged = {}
  5.  
  6. for i in range(n):
  7. a = input().split()
  8. if a[0] == 'register':
  9. if a[1] in users:
  10. print('fail: user already exists')
  11. else:
  12. print('success: new user added')
  13. users[a[1]] = a[2]
  14. logged[a[1]] = False
  15. elif a[0] == 'login':
  16. if a[1] not in logged:
  17. print('fail: no such user')
  18. continue
  19. if not users[a[1]] == a[2]:
  20. print('fail: incorrect password')
  21. continue
  22. if users[a[1]] == a[2] and not logged[a[1]]:
  23. print('success: user logged in')
  24. logged[a[1]] = True
  25. else:
  26. print('fail: already logged in')
  27. elif a[0] == 'logout':
  28. if a[1] not in users:
  29. print('fail: no such user')
  30. elif not logged[a[1]]:
  31. print('fail: already logged out')
  32. else:
  33. print('success: user logged out')
  34. logged[a[1]] = False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement