Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Сделал 2, 5, 6, 4, 8
- def letter_counter(text):
- dic = {}
- for i in text:
- if not dic.get(i):
- dic[i] = 1
- else:
- dic[i] += 1
- ans = list()
- for i in text:
- if dic[i] > 0:
- ans.append((i, dic[i]))
- dic[i] = 0
- return ans
- print(letter_counter("aaaaaaa"))
- def time_formatter(military_time):
- a, b = military_time.split(":")
- a = int(a)
- if a == 0:
- a = 24
- if a > 12:
- return str(a - 12) + ":" + b + " p.m"
- return str(a) + ":" + b + " a.m"
- print(time_formatter("21:00"))
- def is_equals(source_list):
- dic = {}
- for i in source_list:
- dic[i] = True
- return len(dic) <= 1
- print(is_equals([1, 1, 1]))
- def password_checker(password):
- check = [False, False, False, False]
- big = "QWERTYUIOPASDFGHJKLZXCVBNM"
- small = "qwertyuiopasdfghjklzxcvbnm"
- digits = "123456789"
- for i in password:
- if i in big:
- check[0] = True
- if i in small:
- check[1] = True
- if i in digits:
- check[2] = True
- if len(password) >= 10:
- check[3] = True
- return check[0] == check[1] == check[2] == check[3] == True
- print(password_checker("HELld123"))
- print(password_checker('HELLOworld123'))
- def first_longest_unique_substring(source_string):
- ans = ""
- for i in range(len(source_string)):
- for j in range(i, len(source_string)):
- if len(source_string[i:j]) == len(set(source_string[i:j])):
- if len(ans) < len(source_string[i:j]):
- ans = source_string[i:j]
- return ans
- print(first_longest_unique_substring('aaaaa'))
Add Comment
Please, Sign In to add comment