Tuesday, 10 September 2013

Python3 replace using dictionary

Python3 replace using dictionary

Could anyone please explain what is wrong here:
def get_complementary_sequence(string):
dic = {'A':'T', 'C':'G', 'T':'A', 'G':'C'}
for a, b in dic.items():
string = string.replace(a, b)
return string
I get proper results for 'T' and 'C', but 'A' and 'C' won't replace. Got
really stuck.

No comments:

Post a Comment