Advertisement
GeorgiLukanov87

02. Encrypting Password final exam 100/100

Aug 7th, 2022 (edited)
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.22 KB | None | 0 0
  1. # 02. Encrypting Password - Final exam 100/100
  2.  
  3. ========================================================================================================
  4.  
  5. # var1
  6.  
  7. import re
  8.  
  9. n = int(input())
  10. pattern = r'(.+)>(\d{3})\|([a-z]{3})\|([A-Z]{3})\|([^\<\>]{3})<\1'
  11.  
  12. for _ in range(n):
  13.     password = input()
  14.     result = re.findall(pattern, password)
  15.     if result:
  16.         print(f'Password: {result[0][1]}{result[0][2]}{result[0][3]}{result[0][4]}')
  17.     else:
  18.         print('Try another password!')
  19.  
  20.  
  21. ========================================================================================================
  22.  
  23. # var2 functions
  24.  
  25. import re
  26.  
  27.  
  28. def extract_valid_pass_and_print_func(iterations, some_pattern):
  29.     for _ in range(iterations):
  30.         password = input()
  31.         result = re.findall(pattern, password)
  32.         if result:
  33.             print(f'Password: {result[0][1]}{result[0][2]}{result[0][3]}{result[0][4]}')
  34.         else:
  35.             print('Try another password!')
  36.  
  37.  
  38. n = int(input())
  39.  
  40. pattern = r'(.+)>(\d{3})\|([a-z]{3})\|([A-Z]{3})\|([^\<\>]{3})<\1'
  41. extract_valid_pass_and_print_func(n, pattern)
  42.  
  43. ========================================================================================================
  44.  
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement