logo

String ends with?

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


My code:


def solution(text, ending):
    ending_lenght = len(ending)
    last_text = text[-ending_lenght:]
    if last_text == ending:
        return True
    else:
        return False                    
                    


And that's the best solution among all users:


def solution(string, ending):
    return string.endswith(ending)