关闭。这个问题是not reproducible or was caused by typos .它目前不接受答案。
想改进这个问题?将问题更新为 on-topic对于堆栈溢出。
7年前关闭。
Improve this question
我被要求:
Write a function called
start_codon
which accepts a DNA sequence as its argument and returns the first codon as a string.
这是我到目前为止所拥有的:
#!/usr/bin/python
def start_codon(dna):
codon1 = dna[0:3]
codonstring = codon1.split(",");
return codonstring
print (start_codon(“ATGGAACCAACGTCAGTGACTTCGTCAG”))
但是,当我按 Enter 键尝试调用该函数时,出现语法错误:
File "<stdin>", line 1
print (start_codon(“ATGGAACCAACGTCAGTGACTTCGTCAG”))
^
最佳答案
您的 string literal格式不正确。您必须使用引号 "..."
或撇号 '...'
:
print (start_codon("ATGGAACCAACGTCAGTGACTTCGTCAG"))
# or
print (start_codon('ATGGAACCAACGTCAGTGACTTCGTCAG'))
“
和 ”
是 Python 无法识别的特殊字符。
关于python - 定义和调用函数时出现语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26742093/