title: local variable 'count' defined in enclosing scope on line 10 referenced before assignment
body: <p>I am having an issue with the following code of Python 3 (the line at 5th position from bottom <em>count=count+1</em>):</p>
  
  <pre class="lang-py prettyprint-override"><code>import base64
  import json
  from google.cloud import iot_v1
  import os
  from twilio.rest import Client
  
  account_sid = os.environ['TWILIO_ACCOUNT_SID']
  auth_token = os.environ['TWILIO_AUTH_TOKEN']
  client = Client(account_sid, auth_token)
  count = 0
  
  
  def device_config(config):
      client = iot_v1.DeviceManagerClient()
      name = client.device_path(&lt;project_ID&gt;,
                                &lt;Region&gt;,  &lt;Registry&gt;, &lt;Device_ID&gt;)
      binary_data = bytes(config, 'utf-8')
      client.modify_cloud_to_device_config(name, binary_data)
  
  
  def hello_pubsub(event, context):
      if 'data' in event:
          data = event['data']
          data = base64.b64decode(data)
          data = data.decode('utf-8')
          data = json.loads(data)
  
          temperature = float(data['temperature'])
  
          if temperature &gt; 25.0:
              device_config("ledon")
              if count &lt; 1:
                  client.calls.create( \
                      url=&lt;URL&gt;,
                      to=os.environ['TWILIO_TO'],
                      from_=os.environ['TWILIO_FROM'])
                  count = count+1
          else:
              device_config("ledoff")
      else:
          print("Data is not present!")
  
  </code></pre>
  
  <p>This function will be called continuously (imagine like an infinite loop will call this function). I want to update count by 1 when first time temperature goes above 25 and for later calls, how high it may go, LED should be on, but calling shouldnot be done</p>