title: Why does using an integer value as a 'while' loop condition work in Python?
body: <p>The following code will output infinite lines of "test". </p>
  
  <pre><code>foo = 5
  while foo:
      print("bar")
  </code></pre>
  
  <p>The other day I came across an answer here about digit sums. This was the code shown in the answer:</p>
  
  <pre><code>def digit_sum(t):
      s = 0
      while t:
          s += t % 10
          t //= 10
      return s
  </code></pre>
  
  <p>The part I'm focusing on is the "while t:" part. How and why does this work?</p>