Check if String EndsWith in Python

The challenge

Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).

Examples:

strEndsWith('abc', 'bc') # returns true strEndsWith('abc', 'd') # returns false
Code language: Python (python)

The solution in Python

def solution(string, ending): return string.endswith(ending)
Code language: Python (python)

Test cases to validate our solution

test.assert_equals(solution('abcde', 'cde'), True) test.assert_equals(solution('abcde', 'abc'), False) test.assert_equals(solution('abcde', ''), True)
Code language: Python (python)
Tags:
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments