I'm trying to debug a function one_away like this:
import pdb
def is_one_away(first: str, other: str) -> bool:
skip_diff = {
-1: lambda i: (i, i + 1),
1: lambda i: (i + 1, i),
0: lambda i: (i + 1, i + 1)
}
try:
skip = skip_diff[len(first) - len(other)]
except KeyError:
return False
pdb.set_trace()
for i, (l1, l2) in enumerate(zip(first, other)):
if l1 != l2:
i -= 1
break
And to call it I write:
import one_away
one_away.is_one_away('pale', 'kale')
When running to pdb.set_trace(), I'd like to see the result of zip(first ,other). So I write:
(Pdb) >? list(zip(first, other))
*** Error in argument: '(zip(first, other))'
But if in Python console, it works:
>>>list(zip('pale', 'kale'))
[('p', 'k'), ('a', 'a'), ('l', 'l'), ('e', 'e')]
Why?