Write a program that uses a function which takes two string arguments and returns the string comparison result of the two passed strings.
Answer:
def string_compare
(str1,str2):
if
len(str1)!=len(str2):
return
False
else
:
for
i
in
range(len(str1)):
if
str1[i] != str2[i]:
return
False
else
:
return
True
string1=input(
"Enter string 1: "
)
string2=input(
"Enter string 2: "
)
f=string_compare(string1,string2)
if
f ==
True
:
print(
"Strings are same"
)
else
:
print(
"Strings are different"
)