0

I have some code which asks a question and then accepts an input. This input is defined as the variable dna and then examined for instances of the ATG start codon. I keep getting the error:

 Traceback (most recent call last):
    File "DNA_For_Fun_project.py", line 3, in <module>
      dna = input()
    File "<string>", line 1, in <module>
 NameError: name 'ATATGCCTGATGCCTGATCTACTAATGCCTAGTATATGCCC' is not defined

from the code:

print("Copy/Paste a Section of a DNA strand here to find the start codon locations")
dna = input()
maxIndex = len(dna) - 2  # needs to stop once it prints the last 3 letter codon
a = 0
while (a <= maxIndex):  #looks for ATG in the strand until it reaches the end
    a +=1
    try:
        if (dna[a:a+3] == "ATG"):
            print "Index", a, "contains start codon"
    except ValueError:
        print("Please make sure your DNA strand only consists of Capital letters")

Just in case this matters I am running the 2.7 version of python on my computer. I would describe myself as beginner with python still. I understand what most NameErrors are caused by, (local variables being called globally and thus being undefined) but my variable is defined and that is what I don't understand.

Thank you in advance to anyone who replies,

Jm2rv

jm2rv
  • 29
  • 2
  • 1
    possible duplicate of ["NameError: name '' is not defined" after user input in Python](http://stackoverflow.com/questions/2090706/nameerror-name-is-not-defined-after-user-input-in-python) – Ignacio Vazquez-Abrams Sep 26 '14 at 00:25
  • Thank you, I thought my computer was runnning python 3, and didn't remember the raw_input function in python 2. – jm2rv Sep 26 '14 at 01:36

0 Answers0