You are on page 1of 1

PYTHON PROGRAMMING APPLICATIONS LAB

Exercise: Functions-Continued
a)Write a function nearly equal totest whether two strings are nearly equal. Two
and b are nearly equal when a can be generated by a single stringsa
Source code : mutation on b.

def nearly_equal(sl,$2):
count=0
ij-0
while(i<len(sl )and j<len(s2)):
iftsl[i]!=s2iD:
countt=l
if(count> 1):
return False

if(count<2):
return True
sl=input("enter stringl:")
s2=input("enter string2:")
itlnearly cqual(sl,s2)):
print("Strings are nearly Equal")
else:
print("Strings are NOT Equal")
Qutput:
enter stringl:Engineering
enter string2:Engg
Strings are nearly Equal

enter stringl:Engineering
enter striìng2:English
Strings are NOT Equal

You might also like