From 3d9ea5c0e4e817d5776674ffca31bdb5c168e0a6 Mon Sep 17 00:00:00 2001 From: shariik Date: Tue, 16 Dec 2025 11:45:10 +0500 Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=2010?= =?UTF-8?q?=20=D0=BF=D0=B0=D1=80=D0=B0=D0=B3=D1=80=D0=B0=D1=84=203.1=20?= =?UTF-8?q?=D1=81=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 3.1_lesson.10.20.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 3.1_lesson.10.20.py diff --git a/3.1_lesson.10.20.py b/3.1_lesson.10.20.py new file mode 100644 index 0000000..c4772d5 --- /dev/null +++ b/3.1_lesson.10.20.py @@ -0,0 +1,28 @@ +***Задание 2 Параграф 3.1*** +***Напишите программу, которая читает строки до тех пор, пока не встретится строка 'ФИНИШ', и выводит наиболее часто встречающуюся букву (в нижнем регистре).*** + + + +if name == "main": + # простой код + + text = '' + + while (string := input()) != 'ФИНИШ': + text += string.lower() + + text = text.replace(' ', '') + + maximum = 0 + most_frequent_char = '' + + for char in text: + count = text.count(char) + if count > maximum: + maximum = count + most_frequent_char = char + elif count == maximum: + if char < most_frequent_char: + most_frequent_char = char + + print(most_frequent_char.lower()) \ No newline at end of file