I have a list of sentences. For example:
x = ['Mary had a little lamb',
'Jack went up the hill',
'Jill followed suit',
'i woke up suddenly',
'I just missed the train',
'it was a really bad dream']
I want to select those options in which the penultimate word is not 'the'. How could i do it on python 3? I tried this:
l = []
for i in x:
for k in i:
if i.index(k) != (len(i) -2):
l.append(' '.join(i))
I works on a small lists but not on huge ones(several thousands elements)