add KR
CI Check / lint-and-check (push) Failing after 8s

This commit is contained in:
Igor
2026-07-14 23:11:34 +03:00
parent da02f5305a
commit 8623d967f0
5 changed files with 115 additions and 75 deletions
+22
View File
@@ -0,0 +1,22 @@
def safe_input():
while True:
try:
text = input("Введите строку")
if not text.strip():
raise ValueError
return text
except ValueError:
print("Строка не может быть пустой")
def count_chars(text):
my_list = {}
for char in text.replace(" ", ""):
my_list[char] = my_list.get(char, 0) + 1
return my_list
def get_top_tuples(my_list):
return sorted(my_list.items(), key=lambda x: x[1], reverse=True)
print(get_top_tuples(count_chars(safe_input())))