Вот простой пример:
Код: Выделить всё
my_list = ['one', 'two', 'three', 'four', 'five', 'six', 'five']
new = []
for i in my_list:
if i == 'five':
context = (my_list[my_list.index(i)-3], my_list[my_list.index(i)-2], my_list[my_list.index(i)-1])
print(context)
Код: Выделить всё
('two', 'three', 'four')
('two', 'three', 'four')
Код: Выделить всё
('two', 'three', 'four')
('four', 'five', 'six')
Подробнее здесь: https://stackoverflow.com/questions/787 ... s-elements