How to find words next to the found word? I want to see the left word AND the right word of the found word x too.
I was able to extract the index of the found word in the sourcetext. But by doing sourcetext[sourceindex+1] it gives me just the letter of that word. It should give me the next word next to the found word. What am I doing wrong?
sourcetext=browser.page_source
searchword= ["hello","world","pretty","life"]
for x in searchword:
if x in sourcetext:
sourceindex=sourcetext.index(x)
print("FOUND!" + x + " " + sourcetext[sourceindex+1])
else:
continue