I am iterating through two lists like so:
list1 = [z]
list2 = [z-t,z-s,s-a,a-n, g-z]
for e in list1:
 for t in list2:
  # if item from list2 contains item from list1 (before "-")
  # remove the item from list2 and append part after "-" to list1
  # iterate again until no change is made or list2 is empty
The problem I can't solve is that when I remove the item from list2 it goes to next item and I am not able to prevent it. For example
list2 = [z-t,z-s,s-a....]
          ^ removing this while iterating
next iteration jumps over one item
list2 = [z-s, s-a,...]
               ^ this is where I am second iteration
list2 = [z-s, s-a,...]
          ^ this is where I want to be
Is there any way to do this?
 
    