title: Rearranging a variable size list by an inputted positions
body: <p>I need some advice on how to rearrange a list of names like, <code>[&quot;A&quot;, &quot;B&quot;, &quot;C&quot;, &quot;D&quot;]</code>, using an inputted order of positions like, <code>[3,1,4,2]</code>.</p>
  <p>The problem is that the size of the name list is variable from <code>1</code> to <code>4</code> and the positions are also variable, based on an input. Their length is the same, so when there are 3 names, there are 3 values in the positions.</p>
  <p>In the basic non-rearranged list of names <code>[&quot;A&quot;, &quot;B&quot;, &quot;C&quot;, &quot;D&quot;]</code>, the position of the values: <code>A is 1, B is 2</code> and so on.</p>
  <p><strong>Example:</strong> non-rearranged names are [&quot;Mat&quot;, &quot;Bara&quot;, &quot;Tom&quot;] so Mat is 1, Bara is 2, Tom is 3</p>
  <p><strong>Example:</strong> new positions should be [3,1,2]</p>
  <p><strong>Example:</strong> rearranged list would be [&quot;Tom&quot;,&quot;Mat&quot;,&quot;Bara&quot;]</p>
  <p>So far I have tried things like <code>names[positions[i]]</code> and a handful of other things, but no luck.</p>
  <p>this is the very simple code so far:</p>
  <pre><code>num = 0
  pos_list = []
  name_list = []
  
  num = int(input(&quot;how many names:&quot;))
  for i in range(num):
      name = input(&quot;input name:&quot;)
      name_list.append(name)
      pos = int(input(&quot;enter the positions that the names should be arranged to:&quot;))
      pos_list.append(pos)
  
  # first name entered is 1, the second name entered is 2 so on...
  # now they have to be rearranged by the inputted positions
  
  </code></pre>
  <p>Any advice appreciated :)</p>