title: if else statement in a for loop to append to a list
body: <p>I can't understand why the list doesn't append in pyspark. Can someone help look at my code? </p>
  
  <pre><code>import json
  
  input_file = sc.textFile("data.json")
  
  def extract_func(data):
      c_list = []
      neighborhoods = data.get('neighborhoods', None)
  
      for n in neighborhoods:
          if n == []:
              c_list.append('Unknown')
          else:
              c_list.append(n)
  
      return c_list
  </code></pre>
  
  <p>Example data entry: </p>
  
  <pre><code>{'attributes': {'Accepts Credit Cards': True,
   'city': 'Edinburgh',
   'name': 'Conan Doyle',
   'neighborhoods': [],
   'stars': 3.5,
   'state': 'EDH'}}
  </code></pre>
  
  <p>This example entry doesn't have a neighborhood shown, so I want to append 'unknown' to the list. Some other data entries have multiple neighborhoods, so I want to append them individually by the for loop. </p>
  
  <p>When I run <code>dat = input_file.map(lambda line: json.loads(line))</code> followed by <code>dat = dat.flatMap(extract_func)</code>, it doesn't give me the <code>Unknown</code> neighborhood entries. </p>
  
  <p>Being checking for hours, can't figure out what's wrong, what am I missing here? </p>