title: Count variable outside custom function
body: <p>Trying to set up a function that counts the number float values contain inside a txt file when exceeds a custom limit:</p>
  <pre><code>count_out = 0 
  def testing(txts, limit, count_in):
     #tried global but doesn't work
     global count_out
     
     text = text.strip()
     values = float(text)
     
     if values &gt; limit:
       count_in += 1
     return count_in
  </code></pre>
  <p>However currently, it doesn't count the number of values pass through the limit and remain at default value of 0 :</p>
  <pre><code>for a in open('sample.txt'):
    testing(a, 35, count_out)
  
  print(count_out)
  </code></pre>
  <p>The values within the sample.txt are:</p>
  <pre><code>28.8
  49.5
  29.0
  27.6
  35.7
  </code></pre>