我的代码工作得不错,但我不明白为什么它只使用第一项表单搜索列表进行搜索。这是我的代码:
def analyzeSequence(dnastring,searchList):
empty = {}
for item in searchList:
if dnastring.count(item) > 1:
position = dnastring.index(item)
times = dnastring.count(item)
new = position, times
empty[item] = new
return empty
seq = "ATGCGATGCTCATCTGCATGCTGA"
sList = ["CAT","GC"]
print(analyzeSequence(seq,sList))
它打印:
{'CAT': (10, 2)}
但我想把它打印出来:
{'CAT': (10, 2), 'GC': (2, 4)}
您不能在第一次进入
return
时if
,只能在最后返回如果你感兴趣,这里是听写理解的方法
相关问题 更多 >
编程相关推荐