I wrote this program and I am having trouble integrating it with another program I wrote. I believe that the way this program is written is causing my difficulty. Any suggestions for a different approach would be much appreciated.
This program takes two strings and determines is they are exact matches, differ by one character, or if they differ by more than one character. If they are exact matches or differ by one character, it returns True; if they differ by more than one character, it returns false.
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 >= len(strL1) - 1:
print True
else:
print False