Для таких вещей существует функция pairwise: from itertools import pairwise
print(*filter(lambda t: (t[0] & t[1]) < 0, pairwise(map(int, input().split())))) Или так: from itertools import pairwise
print(*((x, y) for x, y in pairwise(map(int, input().split())) if (x & y) < 0))
Пример. Вводим: 1 2 3 -4 -5 6 -7 -8 -9 -10 11 12 -13 -14 Получаем: (-4, -5) (-7, -8) (-8, -9) (-9, -10), (-13, -14)