[Tutor] help with comparing list of tuples in python 2

Lulu J lulu.jama2016 at gmail.com
Fri Jun 17 15:18:47 EDT 2016


Hi there,

My apologies if this is a trivial question but I am sort of new to python.
Here is my problem:
I have a list of dictionaries. Each dictionary has a word and its position
in the text  the positions are in the form of a tuple.
Here is an example:
[
{'position': (5, 4), 'term': u'happy',},
 {'position': (5, 5), 'term': u'something'}
]

for the potions, the first element is the paragraph number and the second
is the word number in that paragraph(sequence from 1...n)

What I would like to is find which words are next to each other. Meaning,
they will be in the same paragraph and the difference of their word numbers
is 1.

Any help would be appreciated.

Thank you


More information about the Tutor mailing list