title: Python Append from a list to another on a condition
body: <p>i'm a python newbie and i want to check if a each list element is present in another list(while respecting the index) and append this element to a third list.  like this. if first element of 'listy'(&quot;11-02-jeej&quot;) contains first element of list_of_dates (&quot;11-02), i want this element &quot;11-02-jeej&quot; to be appended in the first list of a list of lists. the code below doesn't work for me :(</p>
  <pre><code>the output that i want from this code is :[[&quot;11-02-jeej&quot;], [2apples], []]
  but instead i get : [[], [], []] 
  </code></pre>
  <p>thank you so much !</p>
  <pre><code>list_of_dates =[&quot;11-02,&quot;, &quot;2&quot;, &quot;5&quot;]
  listy = [&quot;11-02-jeej&quot;, &quot;2apples&quot;, &quot;d44&quot;]
  length = len(list_of_dates)
  lst = [[] for m in range(length)]
  
  for i in range(len(list_of_dates)):
      date =  list_of_dates[i]
      for j in range(len(listy)):
           name = listy [j]
      if date in name:
          lst[m].append(name)
  
  print(lst)
  </code></pre>