For a task in school we have to develop a programme that will take a piece of text from the user turn this to a list and then find all positions of a word that the user has searched for within the text.
I have found multiple ways to nearly do this but they all have a slight downfall somewhere along the line. Apart from one but this has one line I do not understand and therefore I was wondering if anyone could explain this to me.
The line of code is position = [I for I, x in enumerate(text2) if x == (word)]