title: iterating through for loop and if condition not satisfied do something. python
body: <p>I have following condition:</p>
  
  <pre><code>a=[]
  for i in list1:
      for j in list2:
          if i==j:
              a.append(i)
  </code></pre>
  
  <p>I want to add a statement <code>a.append(np.nan)</code> if i!=j after looping through list2.
  i.e<br>
  After iterating through inner for loop, if i don't find any i==j then it should append <code>nan</code>.
  PS.: I have such lists that there will be at-most once <code>i==j</code>.</p>
  
  <p>How to do it?</p>