我有一些代码询问问题,然后接受输入。该输入被定义为变量dna,然后检查ATG起始密码子的实例。我一直收到错误:
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
来自代码:
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")
以防万一我在计算机上运行2.7版本的python。我会用python描述自己是初学者。我理解大多数NameErrors是由什么引起的,(局部变量被全局调用,因此是未定义的)但我的变量是定义的,这是我不理解的。
提前感谢任何回复的人,
Jm2rv