Advertisement
yordan_yordanov

p2

Dec 13th, 2020
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. import re
  2.  
  3. n = int(input())
  4. count = 0
  5.  
  6. for i in range(n):
  7. registration = input()
  8. username_pattern = r"U\$([A-Z][a-z]{2,})U\$"
  9. password_pattern = r"P@\$([A-Za-z]{5,}\d+)P@\$"
  10. pattern = f"{username_pattern}{password_pattern}"
  11.  
  12. match = re.match(pattern, registration)
  13.  
  14. if match is None:
  15. print('Invalid username or password')
  16. continue
  17.  
  18. count += 1
  19. print("Registration was successful")
  20. print(f'Username: {match[1]}, Password: {match[2]}')
  21.  
  22. print(f'Successful registrations: {count}')
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement