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" my if statement is
[inline]'if (x=="tga" or x=="tag" or x=="taa"):
do something
[/inline]
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.
[inline]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)[/inline]
[inline]'if (x=="tga" or x=="tag" or x=="taa"):
do something
[/inline]
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.
[inline]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)[/inline]