title: Return statement in a if/else statement doesn't return value in Python
body: <p>In this function I would like to return a list if it's not empty. To check is the list is empty I use the <code>if not data:</code> and to test if it is filled with something I use <code>elif data:</code> but the <code>return</code> statement is not executed when <code>len(data)</code> equal to 13. What could be the reason? </p>
  
  <p>When the list is empty the function is called again with new <code>start</code> and <code>end</code> parameters until <code>data</code> is filled with something.</p>
  
  <pre><code>Class MyClass:
  
      def downloadHistoryOHLC(url, start, end):
  
          http = urllib.request.urlopen(url)
          data = json.loads(http.read().decode())
  
          print('length is', len(data))      # Here I test if list is filled  
  
          if not data:
  
              ''' Add 366 days to start date if list is empty '''
  
              start = datetime.strptime(start, '%Y-%m-%dT%H:%M:%SZ') + timedelta(days=366)
              start = str(start.isoformat()+'Z')
  
              end = datetime.strptime(end, '%Y-%m-%dT%H:%M:%SZ') + timedelta(days=366)
              end = str(end.isoformat()+'Z')
  
              MyClass.downloadHistoryOHLC(url, start, end) # if list is empty I execute the same function with new parameters
  
          elif data:
  
              return data
  </code></pre>
  
  <p>When I execute the function I can see the length of the list is 13 but no data is returned.</p>
  
  <pre><code>In [844]: mylist = MyClass.downloadHistoryOHLC(start, end, coin_id, name)
  length is 0
  length is 0
  length is 0
  length is 0
  length is 13
  
  In [845]: mylist
  
  In [846]:
  </code></pre>