def anagramSolution1(s1,s2): alist = list(s2) pos1 = 0 still0k = True while pos1 < len(s1) and still0k: pos2 = 0 found = False while pos2 < len(alist) and not found: if s1[s1] == alist[pos2]: found = True else: pos2 = pos2 + 1 if found: alist[pos2] = None else: still0k = False pos1 = pos1 + 1 return still0k print(anagramSolution1('abcd','dcba'))修改错误
时间: 2023-06-10 09:07:36 浏览: 151
def anagramSolution1(s1,s2):
alist = list(s2)
pos1 = 0
still0k = True
while pos1 < len(s1) and still0k:
pos2 = 0
found = False
while pos2 < len(alist) and not found:
if s1[pos1] == alist[pos2]:
found = True
else:
pos2 = pos2 + 1
if found:
alist[pos2] = None
else:
still0k = False
pos1 = pos1 + 1
return still0k
print(anagramSolution1('abcd','dcba'))
阅读全文