In python what does [pos for pos, word in enumerate(sentence, start=1) if word == word_positions] actually do in my code?
<p>I know this question comes off as a bit, silly, I mean, I wrote the code! This particular bit of code however I got off a website I can no longer find, and I need to do a write up on the code.</p>

<p>Here's the code:</p>

<pre><code>sentence = input("Please input a sentence\n").lower().split() 
# Assigns a sentence to a variable, puts it into lower case and then splits the string into words

word_positions = input("Please input a word\n") 
# Assigns a word for the program to print its positions 

end = [pos for pos, word in enumerate(sentence, start=1) if word == word_positions]

print (end)
# prints the positions of the word
</code></pre>

<p>The results of running the code look like:</p>

<pre><code>Please input a sentence
The cat sat on the mat
Please input a word
the
[1, 5]
</code></pre>

<p>Its just <code>[pos for pos, word in enumerate(sentence, start =1) if word == word positions]</code> that I need to know what it does. </p>