title: while loop with dynamic list in python using a dictionnary
body: <p>I have a dictionary with lots of data from a CSV file where the key is the row number and the value is a list that contains the column data.</p>
  <p>What I want to do is to check from a data of each line (key) and from column 2, I take its data from column 4 and then look for this data in column 2 of another line (key) and take its data in column 4 and continue until it finds the last value of column 4 in column 2.</p>
  <p>My code is this:</p>
  <pre><code>dict_FH_coord = self.dict_FH() 
  site_SI='some_site'       
  list_test = [site_SI]
  
  while len(list_test) &gt; 0:
      for ele in list_test:
          for cle, val in dict_FH_coord.items():
              list_test = []
              if val[2] == ele:
                  list_test.append(val[4])
                  list_def.append(val)
                  print(val)
  </code></pre>
  <p>But this code does not work because it stops at the first iteration and it finds that the elements linked to the starting <code>site_SI</code> only</p>
  <p>Is there a way to do successive iterations with the list <code>list_test</code> which becomes dynamic to solve my problem?</p>