What did I do wrong with this function?
Posted
by
Felipe Galdino Campos
on Stack Overflow
See other posts from Stack Overflow
or by Felipe Galdino Campos
Published on 2012-10-21T22:54:43Z
Indexed on
2012/10/21
23:00 UTC
Read the original article
Hit count: 227
python
I don't know what I did - it's wrong . Can someone help me?
def insert_sequence(dna1, dna2, number):
'''(str, str, int) -> str
Return the DNA sequence obtained by inserting the second DNA sequence
at the given index. (You can assume that the index is valid.)
>>> insert_sequence('CCGG', 'AT', 2)
'CCATGG'
>>> insert_sequence('TTGC', 'GG', 2)
'TTGGGC'
'''
index = 0
result = '';
for string in dna1:
if index == number:
result = result + dna2
result = result + string
index += 1
print(result)
© Stack Overflow or respective owner