I am trying to write a function that takes a string of DNA and returns the compliment. I have been trying to solve this for a while now and looked through the Python documen
For a problem like this, you can use string.maketrans (str.maketrans in Python 3) combined with str.translate:
import string table = string.maketrans('CGAT', 'GCTA') print 'GCTTAA'.translate(table) # outputs CGAATT