Skip to main content
Stack Overflow
  1. About
  2. For Teams

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

Python String function

Looking to put together a simple python function that checks the following

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").

end_other('Hiabc', 'abc') → True
end_other('AbC', 'HiaBc') → True
end_other('abc', 'abXabc') → True

Answer*

Draft saved
Draft discarded
Cancel
2
  • the slicing method above implies that s1 will always be Hiabc, what if it wasnt ? str.endswith sounds better ? how can i make str1 the value of the first string and str2 the value of the second one, ? i cant hard code these cos they are different in each line . Commented Oct 20, 2015 at 7:50
  • @johndoe12345 My answer shows you path you should follow. You should go ask google how to define functions in python and try to solve rest of the problem by yourself. Commented Oct 20, 2015 at 7:53

lang-py

AltStyle によって変換されたページ (->オリジナル) /