Предмет: Информатика, автор: alexunder005

Python Вивести на екран три найпоширеніші символи в рядку TRANSLATE with x
English
Arabic Hebrew Polish
Bulgarian Hindi Portuguese
Catalan Hmong Daw Romanian
Chinese Simplified Hungarian Russian
Chinese Traditional Indonesian Slovak
Czech Italian Slovenian
Danish Japanese Spanish
Dutch Klingon Swedish
English Korean Thai
Estonian Latvian Turkish
Finnish Lithuanian Ukrainian
French Malay Urdu
German Maltese Vietnamese
Greek Norwegian Welsh
Haitian Creole Persian

Ответы

Автор ответа: TemaZpro
0

Код на языке Python:

from collections import Counter

def get_top_three_chars(string):

   char_counts = Counter(string)

   

   sorted_chars = sorted(char_counts.items(), key=lambda x: x[1], reverse=True)

   

   top_three_chars = [char for char, count in sorted_chars[:3]]

   

   return top_three_chars

input_string = input("Введите строку: ")

top_chars = get_top_three_chars(input_string)

print("Три наиболее часто встречаемых символа:")

print(top_chars)

Интересные вопросы