Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Solution: DNA sequencing with filter

dna = 'ACCGXXCXXGTTACTGGGCXTTGT'
sequences = dna.split('X')
sequences.sort(key=len, reverse=True)

def not_empty(x):
    return len(x) > 0

print(sequences)
sequences = list( filter(not_empty, sequences) )
print(sequences)