How to print words (and punctuation) from a list of positions
<p>(Removed Code to stop Class mates copying)
Right now it will create a text file with positions of each word, so for example if I wrote</p>

<p>"Hello, my name is mika, Hello" </p>

<p>The positions in that list would be [1,2,3,4,5,6,2,1], and it will also list each word/punctuation but only once, so in this case it would be </p>

<p>['Hello', ',', 'my', 'name', 'is', 'mika'] </p>

<p>The only thing now is to be able to get the words back into the original sentence using those positions in the list, which I can't seem to do.
 I did try searching for other posts but it seemed to come up only with other people wanting the positions of the words rather than wanting to put the words back into a sentence using the positons. 
I also thought it could be started by doing this:</p>

<pre><code>for i in range(len(readlines[1])):
</code></pre>

<p>but I honestly have no idea how to go around doing this.</p>

<p>Edit: This has now been solved by @Abhishek, thank you.</p>

<p>You can use <code>numpy</code> to do this.</p>

<pre><code>&gt;&gt;&gt; import numpy as np
&gt;&gt;&gt; indices = np.array([1,2,3,4,5,6,2,1])
&gt;&gt;&gt; namelst = np.array(['Hello', ',', 'my', 'name', 'is', 'mika', ',', 'Hello'])
&gt;&gt;&gt; ' '.join(namelst[indices-1])
'Hello , my name is mika , Hello'
</code></pre>

python list