Use enumerate to find indices of all words with letter 'x'
<p>How use enumerate to help find the indices of all words containing 'x' </p>

<p>Thank you</p>

<pre><code>wordsFile = open("words.txt", 'r')
words = wordsFile.read()
wordsFile.close()
wordList = words.split()

indices=[]

for (index, value) in enumerate(wordList):
    if value == 'x':

print("These locations contain words containing the letter 'x':\n",indices)
</code></pre>

<p>Your code is almost complete:</p>

<pre><code>for (index, value) in enumerate(wordList):
    if 'x' in value:
        indices.append(index)
</code></pre>

<p>This checks, for every single word, if there is an <code>x</code> in it. If so, it adds the index to <code>indices</code>.</p>

python python-3.x