What is wrong with the variable comparison in this one?


#1



It gives me a syntax error at line 4, but it seems fine to me. What is wrong?


File "python", line 4
for x < len(DNA):
^
SyntaxError: invalid syntax


RNA=[]
def transcription(x):
    DNA=raw_input("Please enter DNA sequence:")
    for x < len(DNA):
        if DNA(x)!=("A" or "T" or "C" or "G"):
            print "This sequence is invalid."
            transcription(x)
        elif DNA(x)=="A":
            RNA.append("U")
        elif DNA(x)=="T":
            RNA.append("A")
        elif DNA(x)=="C":
            RNA.append("G")
        else:
            RNA.append("C")
        print RNA
transcription(0)


#2

This does not look right. Did you mean to write,

for x in range(len(DNA):

?

This does not look right, either.

if DNA[x] not in "ATCG":

Pretty sure this is not a lesson in the Python track. Please post a link to this exercise.


#3

It is not actually an exercise... Is that what this forum is about? I thought it was a general purpose forum for programming.
And yeah, I realised the 2nd point myself. Thanks for the 1st, though- this one went right over my head.
Now, I got a new problem though. WOuld you mind checking it out? I'm a PITA, I know, but I just cannot figure this out.

File "python", line 20
if (len(RNA) mod 3) == 0:
^
SyntaxError: invalid syntax

RNA=[]
def transcription(x):
DNA=raw_input("Please enter DNA sequence:")
for x in range(len(DNA)):
if DNA[x]=="G":
RNA.append("C")
elif DNA[x]=="A":
RNA.append("U")
elif DNA[x]=="T":
RNA.append("A")
elif DNA[x]=="C":
RNA.append("G")
else:
print "This sequence is invalid."
del RNA[ : ]
transcription(0)
print "The resulting RNA has the sequence:"
print "".join(RNA)
def translation(y):
if (len(RNA) mod 3) == 0:
y=raw_input("is your chosen genome mature? Please type Yes or No.")
if y=="Yes":
z=1
codon=[]
peptide=[]
codon.append(RNA[0])
codon.append(RNA[1])
codon.append(RNA[2])
if codon!=["A","U","G"]:
print "This RNA is not translatable."
else:
peptide.append("Met")
for z in range(len(RNA)/3):
codon.append(RNA[3*z])
codon.append(RNA[3*z+1])
codon.append(RNA[3*z+2])
if codon==["A","A","A"] or [
transcription(0)


#4

That would be Corner Bar, where I'll be moving this topic. These forums are dedictated to the course track modules.

if len(RNA) % 3 == 0:

#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.