title: How do I differentiate between a tab and a space in a string in python
body: <p>I'm trying to write a function that finds the most common delimiter of a string, it's either a comma, a space or a tab. My issue is that the function doesn't read tabs and instead reads them as a bunch of spaces. Here's the code I have: </p>
  
  <pre><code>def which_delimiter(input_str):
  
      # count total number of spaces, commas and tabs in the string
      spaces = input_str.count(" ")
      commas = input_str.count(",")
      tabs = input_str.count("\t")
  
      # return the delimiter with the highest frequency
      # if there is none, raise an error
      if spaces == 0 and commas == 0 and tabs == 0:
          raise AssertionError
      elif spaces &gt; commas and spaces &gt; tabs:
          return "spaces"
      elif commas &gt; spaces and commas &gt; tabs:
          return "commas"
      else:
          return "tabs"
  </code></pre>