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