I have a list of incorrect words called # words[] and another list containing my txt file # text[].
I want to print the line number of the words located in the text.
I get the following error for my code.
invalid syntax: print(text, d[counter])
I am trying to print the words with its line number located in the text but it is not working its only printing the words anyone know why?
Below is the last bit of code start from d = {}
I want to print the line number of the words located in the text.
I get the following error for my code.
invalid syntax: print(text, d[counter])
I am trying to print the words with its line number located in the text but it is not working its only printing the words anyone know why?
Below is the last bit of code start from d = {}
Code:
d = {}
counter = 0
for lines in words:
text = lines.split()
counter += 1
if text not in d:
d[text] = [counter]
if text in d:
d[text.append[counter]
print(text, d[counter])
Comment