def count_end(teststr, testchar):
    """Count instances of testchar at end of teststr."""
    count = 0
    x = len(teststr) - 1
    while x >= 0 and teststr[x] == testchar:
        count += 1
        x -= 1
    return count
def count_end ( teststr , testchar ) : count = 0 x = len ( teststr ) - 1 while x >= 0 and teststr [ x ] == testchar : count += 1 x -= 1 return count
Count instances of testchar at end of teststr.