generate functionTue, 21 Mar 2023

Напишите программу, которая находит рекордное количество вхождений (не обязательно подряд) символа в строку.

def find_record(string): counter, prev_char, max_count = 1, '', 0 for char in string: if char == prev_char: count += 1 else: prev_char = char count = 1 if count > max_count: max_count = count return max_count find_record('hahahahahahahahah') # => 13

Questions about programming?Chat with your personal AI assistant