I’m given the following DNA string:
mydna = 'AGUGGCUAUUACUACAUGCCGAAGUUCCUUAAAUUUAACUUACCAGGCUUAACCGGAUGAUGAUUAUUAUUACCUUAAUUUUA'
How can I get the DNA string’s complement?
>Solution :
No fancy stuff:
original_strand = 'AGUGGCUAUUACUACAUGCCGAAGUUCCUUAAAUUUAACUUACCAGGCUUAACCGGAUGAUGAUUAUUAUUACCUUAAUUUUA'
new_strand = ''
for char in original_strand: # for every character in the string...
if char == 'A':
replace_with = 'U'
elif char == 'U':
replace_with = 'A'
elif char == 'C':
replace_with = 'G'
elif char == 'G':
replace_with = 'C'
new_strand += replace_with
print(new_strand)