Ejemplo: secuencia consecutiva más larga de Python
def longest(seq = input("""Please enter a series of random letters,
i will guess the largest sequence of letters in order""").upper()):
max_count = 0
max_char = ""
prev_char = ""
for current in seq:
if prev_char == current:
count += 1
else:
count = 1
if count > max_count:
max_count = count
max_char = current
prev_char = current
print(max_char,max_count)
longest()
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)