Quote:Every time I run it, it says return outside function. What do I do?
With Python, indentation
matters, it is the structure of your program
, it is not just presentation. Need to be extra careful with it.
chars = "ACGT"
def neighbors(pattern, d):
assert(d <= len(pattern))
if d == 0:
r2 = neighbors(pattern[1:], d-1)
r = [c + r3 for r3 in r2 for c in chars if c != pattern]
if (d < len(pattern)):
r2 = neighbors(pattern[1:], d)
r += [pattern + r3 for r3 in r2]