title: Local variable referenced before assignment in Python
body: <pre><code>Truel=&quot;&quot;
  count = 0
  finle_touch=False #true after it find the first 3 upperletter
  
  # check if there is 1 lower letter after three upper letter
  def one_lower(i):
      count=0
      if i == i.lower:
          finle_touch=True
          Truel=i
  
  # check for 3 upper letter
  def three_upper(s):
      for i in s:
          if count == 3:
              if finle_touch==True:
                  break
              else:
                  one_lower(i)
          elif i == i.upper:
              count +=1
              print(count) #for debug
          else:
              count ==0
              finle_touch=False
  
  stuff=&quot;dsfsfFSfsssfSFSFFSsfssSSsSSSS.......&quot;
  three_upper(stuff)
  print(Truel)
  </code></pre>
  <p>So I have a lot of string on 'stuff' and  I like to find 1 lowercase letter that's surrounded by 3 uppercase letter.</p>
  <p>But when I run this code I get:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;C:\Python33\mypy\code.py&quot;, line 1294, in &lt;module&gt;
      three_upper(stuff)
    File &quot;C:\Python33\mypy\code.py&quot;, line 1280, in three_upper
      if count == 3:
  UnboundLocalError: local variable 'count' referenced before assignment
  </code></pre>
  <p>I don't understand why.</p>