title: Replace an empty string in a list with NaN
body: <p>I am trying to replace an empty string in a list with a known string (say 'NAN'). I am using the following command</p>
  
  <pre><code>a = ['','','asdf']    
  ["nan" if x =='' else x for x in a]
  </code></pre>
  
  <p>The code is working, when it is used standalone, however when I am trying to employ it in my main code, it is not working. My main code is as follows: </p>
  
  <pre><code>data = [ ('plant_data.xlsx', 0, []),('sorg.xlsx', 1, ['','','asdf'])]#,('sloc.xlsx', 1, ['307-040N'])];
  
  
  for fl in data:
      filename = fl[0];
      filename = filename[:-5];
  
      f = open('IC1_Results\%s.txt' %filename,'w');
  
      if fl[1] == 0:
          f.write("All Part Numbers exist");
          f.close()
  
      elif fl[1] == 1:
          a = fl[2];
          print type(a)
  
          ["nan" if x == '' else x for x in a]
  
          print fl[2],a
  </code></pre>