You don't even need that codonsB
list. A codon maps onto its anticodon complement 1:1.
def anticodon(codon):
"""returns the anticodon complement for a given codon"""
return ''.join(pairs[c] for c in codon)
anticodon('AAG')
Out[5]: 'TTC'
You're free to check if each element in codonsA
has an anticodon in codonsB
, if you need to make that check.
all(anticodon(c) in codonsB for c in codonsA)
Out[6]: True
And the output I think you were originally looking for:
for codon in codonsA:
print '{} : {}'.format(codon,anticodon(codon))
AAG : TTC
TAC : ATG
CGG : GCC
GAT : CTA
TTG : AAC
GTG : CAC
CAT : GTA
GGC : CCG
ATT : TAA
TCT : AGA