Profiling shows this is the slowest segment of my code for a little word game I wrote:
def distance(word1, word2): difference = 0 for i in range(len(word
Try this:
def distance(word1, word2): return sum([not c1 == c2 for c1, c2 in zip(word1,word2)])
Also, do you have a link to your game? I like being destroyed by word games