code: def leading_whitespace(self, inputstring):
          
          count = 0
          for i, c in enumerate(inputstring):
              if c == " ":
                  count += 1
              elif c == "\t":
                  count += tabworth - (i % tabworth)
              else:
                  break
              if self.indchar is None:
                  self.indchar = c
              elif c != self.indchar:
                  self.strict_err_or_warn("found mixing of tabs and spaces", inputstring, i)
          return count
docs: Count leading whitespace.