title: Compare strings, allowing one character difference
body: <p>I have been trying to implement tabular method for simplification of boolean expressions in python. For that I need to check whether two given strings differ at only one index
  for example, the function should return the following for the following examples:</p>
  
  <ul>
  <li><code>0011</code> and <code>0111</code> - true as the two differ only at position 1</li>
  <li><code>0-001</code> and <code>0-101</code> - true as differ at only 2</li>
  <li><code>0-011</code> and <code>0-101</code> - false as differ at 2,3</li>
  </ul>
  
  <p>right now I am using the following function:</p>
  
  <pre><code>def match(s1,s2):
  
      l=[False,-1]##returns false when they cant be combined
      for i in range(len(s1)):
          if s1[:i]==s2[:i] and s1[i]!=s2[i] and s1[i+1:]==s2[i+1:]:
              l= [True,i]
              break
      return l
  </code></pre>
  
  <p>I want to implement it in a very fast manner (low complexity). Is there a way to do so in python?</p>