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