Answers for "python longest consecutive sequence"

4

python longest consecutive sequence

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()
Posted by: Guest on December-03-2020

Code answers related to "python longest consecutive sequence"

Python Answers by Framework

Browse Popular Code Answers by Language