azalea says

Don't do things the hardest way

Given a DNA sequence, say DNA = ‘AATTGGCCA’, count how many times a given nucleotide (e.g. ‘A’) appears.

I used to do this in Python:

>>> len(filter(lambda x: x=='A',DNA))

Today, I just find out I can simply do:

>>> DNA.count('A')

Feel silly myself, but begin to love Python even more!

programming python · Tweet Edit