title: Setting values in a list to 0 based on conditions
body: <p>I have a dataframe of lists that look like this:</p>
  
  <pre><code>alist = ['male','male', 'male','female','male, '0', 'female','female','female','male', 'female']
          ['0','female', 'male','female','female, 'male', 'male','male','female','male',]
  </code></pre>
  
  <p>Now, i want to set all 'male' values nested between 'females' to zero, and vice versa, so as to have a list of non-overlapping values. </p>
  
  <pre><code>['male','male', 'male','0','male, '0', 'female','female','female','0', 'female']
  ['0','female', '0','female','female, 'male', 'male','male','0','male',]
  </code></pre>
  
  <p>I have tried this:</p>
  
  <pre><code> for i in alist:
          rules1 = [ i == 'male',   
               i + 1 == 'female',
                i - 1 == 'female']
          rules2 = [ i == 'female',   
               i + 1 == 'male',
                i - 1 == 'male']
          if all(rules1) or all(rules2):
              i = 0
          else:
              i = i
      return alist   
  
  fixlist_['new_tags'] = fixlist_.apply(find_start, axis=1)       
  </code></pre>
  
  <p>I am doing something wrong, but i cant seem to catch it. this code returns an error</p>
  
  <pre><code>----&gt; 9              i + 1 == 'cons',
       10               i - 1 == 'cons']
       11         rules2 = [ i == 'cons',   
  
  TypeError: ('can only concatenate str (not "int") to str', 'occurred at index 0')
  </code></pre>
  
  <p>Thanks all.</p>