Complaining
m = [[0]*(len(s)+1)]*(len(t)+1)
This creates a 2D list but * only copies the list object at the address, not creating new ones. It’s just the same list twice.
m[0][0] = 1
# sets all 0th index values to one
# [[1, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0]]
I’m kinda dumb.
I would use this video to teach me Python again.
The best advice I can give from all of this is: the best way to avoid the surprise of mutable aliasing is don’t mutate values. Write functions like this to make new lists.