prints line number in both txtfile and list?
<p>i have this code which prints the line number in infile but  also the linenumber in words what do i do to only print the line number of the txt file next to the words???</p>

<pre><code>d = {}
counter = 0
wrongwords = []
for line in infile:
infile = line.split()
wrongwords.extend(infile)
counter += 1
for word in infile:
    if word not in d:
        d[word] = [counter]
    if word in d:
        d[word].append(counter)
</code></pre>

<p>for stuff in wrongwords:
    print(stuff, d[stuff])</p>

<p>the output is :</p>

<pre><code>hello    [1,  2,  7,  9] # this is printing the linenumber of the txt file
hello    [1] # this is printing the linenumber of the list words
hello    [1]
what i want is:
hello    [1,  2,  7,  9]
</code></pre>
