Python: Help combining a string locator and a string matcher
<p>I am trying to combine two different programs I wrote into one, and having trouble. The end result will take a parent string and a sub-string as inputs. It will output the locations at which exact matches, or matches that differ by only one character to the sub-string occur within the parent string.</p>

<p>The first program takes a parent string and tries to find a sub-string inside of it.</p>

<pre><code>import string

def subStringMatchExact():
    print "This program will index the locations a given sequence"
    print "occurs within a larger sequence"
    seq = raw_input("Please input a sequence to search within: ")
    sub = raw_input("Please input a sequence to search for: ")
    n = 0
    for i in range(0,len(seq)):
        x = string.find(seq, sub, n, len(seq))
        if x == -1:
            break
        print x
        n = x + 1
</code></pre>

<p>The next program analyzes two strings and returns True if they are an exact match or differ by just 1 character. It returns False if they differ by more than one character.</p>

<pre><code>import string

def similarstrings():
    print "This program will determine whether two strings differ"
    print "by more than one character. It will return True when they"
    print "are the same or differ by one character; otherwise it will"
    print "return False"
    str1 = raw_input("Enter first string:")
    str2 = raw_input("Enter second string:")
    str1 = ' '.join(str1)
    str2 = ' '.join(str2)
    strL1 = string.split(str1, " ")
    strL2 = string.split(str2, " ")
    x = 0
    for i in range(len(strL1)):
        if strL1[i] == strL2[i]:
            x = x + 1
        else:
            x = x
    if x &gt;= len(strL1) - 1:
        print True
    else:
        print False
</code></pre>

<p>I think my issue is stemming from how I wrote the second function. Any advice or suggestions would be much appreciated.</p>
