Given two strings, return True if either of the strings appears at the very end of the other string, ignoring upper/lower case differences (in other words, the computation should not be "case sensitive").
Examples / Tests:
>>> end_other('Hiabc', 'abc')
True
>>> end_other('AbC', 'HiaBc')
True
>>> end_other('abc', 'abXabc')
True
My Code:
def end_other(s1, s2):
s1 = s1.upper()
s2 = s2.upper()
if s1[2:6] == s2:
return True
elif s2[2:6] == s1:
return True
elif s2 == s1:
return True
else:
return False
What I expect is wrong.
(NB: this is a code practice from CodingBat
Any reason you can’t use the built-in functions?
Your code with the arbitrary slices doesn’t make a lot of sense.