I am trying to remove part of a string withing a string. for example if a string is "atgtga" i want the output to be "atg". i tried using the .replace("tga","") method but my TA was saying that it only masks that part of the string instead of removing it.
i tried a new approach but i am still stuck on the if statement.
x="atgtgaacttaa"
c=0
q=3
while(q<=len(x)):
x=x[c:q]
if(x=="tga" or x=="taa" or x=="tag"):
c=c+3
q=q+3
print(x)
I tried making a new function but my output is ignoring "atg" for some reason and deleting it.
def get_orf(dna_seq):
x=0
while(x<=len(dna_seq)):
if("taa" in dna_seq or "tag" in dna_seq or "tga" in dna_seq ):
dna_seq=dna_seq.replace("taa","")
dna_seq=dna_seq.replace("tag","")
dna_seq=dna_seq.replace("tga","")
return dna_seq
else:
return dna_seq
x=x+1