georgiy110802

Untitled

Apr 7th, 2021 (edited)
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. # Сделал 2, 5, 6, 4, 8
  2.  
  3.  
  4. def letter_counter(text):
  5. dic = {}
  6. for i in text:
  7. if not dic.get(i):
  8. dic[i] = 1
  9. else:
  10. dic[i] += 1
  11. ans = list()
  12. for i in text:
  13. if dic[i] > 0:
  14. ans.append((i, dic[i]))
  15. dic[i] = 0
  16. return ans
  17.  
  18.  
  19. print(letter_counter("aaaaaaa"))
  20.  
  21.  
  22. def time_formatter(military_time):
  23. a, b = military_time.split(":")
  24. a = int(a)
  25. if a == 0:
  26. a = 24
  27. if a > 12:
  28. return str(a - 12) + ":" + b + " p.m"
  29. return str(a) + ":" + b + " a.m"
  30.  
  31.  
  32.  
  33. print(time_formatter("21:00"))
  34.  
  35.  
  36. def is_equals(source_list):
  37. dic = {}
  38. for i in source_list:
  39. dic[i] = True
  40. return len(dic) <= 1
  41.  
  42.  
  43. print(is_equals([1, 1, 1]))
  44.  
  45.  
  46. def password_checker(password):
  47. check = [False, False, False, False]
  48. big = "QWERTYUIOPASDFGHJKLZXCVBNM"
  49. small = "qwertyuiopasdfghjklzxcvbnm"
  50. digits = "123456789"
  51. for i in password:
  52. if i in big:
  53. check[0] = True
  54. if i in small:
  55. check[1] = True
  56. if i in digits:
  57. check[2] = True
  58. if len(password) >= 10:
  59. check[3] = True
  60. return check[0] == check[1] == check[2] == check[3] == True
  61.  
  62.  
  63. print(password_checker("HELld123"))
  64. print(password_checker('HELLOworld123'))
  65.  
  66.  
  67. def first_longest_unique_substring(source_string):
  68. ans = ""
  69. for i in range(len(source_string)):
  70. for j in range(i, len(source_string)):
  71. if len(source_string[i:j]) == len(set(source_string[i:j])):
  72. if len(ans) < len(source_string[i:j]):
  73. ans = source_string[i:j]
  74. return ans
  75.  
  76.  
  77. print(first_longest_unique_substring('aaaaa'))
  78.  
  79.  
Add Comment
Please, Sign In to add comment