title: Find out how many zeros a number has at the end (string index out of range error when number is 0)
body: <p>I am trying to solve the problem in the title, and I'm getting an IndexError.</p>
  <pre><code>def count_zeros(number:int) -&gt; int:
      number = str(number)
      i = 0
      j = -1
  
      while number[j] == '0'
          i += 1
          j += -1
  
      return i
  </code></pre>
  <p>This code spits out the IndexError only when the number is 0. I cannot figure out why.</p>
  <pre><code>&gt;&gt;&gt;count_zeros(0)
  
  
  IndexError  Traceback (most recent call last)
  &lt;ipython-input-45-688099e7700c&gt; in &lt;module&gt;
  ----&gt; 1 end_zeros(0)
  
  &lt;ipython-input-43-181de92af60c&gt; in end_zeros(number)
        4     i = 0
        5 
  ----&gt; 6     while number[j] == '0':
        7         i += 1
        8         j -= 1
  
  IndexError: string index out of range
  </code></pre>