【发布时间】:2015-11-10 18:18:36
【问题描述】:
lst = ['a', 'b', 'c', 'aa', 'bb', 'cc']
def findexact(lst):
i=0
key = ['a','g','t']
while i < len(lst):
if any(item in lst[i] for item in key):
print i
i+=1
findexact(lst)
在上面的代码中,结果是:
0
3
我希望结果是:
0
我想获得“精确”匹配的索引。我需要做什么才能获得可接受的结果?
【问题讨论】:
-
您为什么使用与other question 相同的无效算法?
标签: python string indexing find match