Good day to all.
Condition A list of numbers is given. If there are two adjacent elements of the same character in it, output these numbers. If there are no adjacent elements of the same character, do not display anything. If there are several such pairs of neighbors, output the first pair.
http://pythontutor.ru/lessons/lists/problems/same_sign_neighbours/
a = [int(i) for i in input().split()] res = [] for i in range(len(a)-1): if (a[i] > 0 and a[i+1] > 0) or (a[i] < 0 and a[i+1] < 0): res.append(a[i]) res.append(a[i+1]) print(res[0], res[1]) In general, the code may be useful to the same beginners as I, because in general I did everything more or less correctly. He did elementary. Traversing the list, adding to the end of the new list of two adjacent elements with one sign. Output only the first two elements of the new list, in case there are several such pairs. It passes all the tests, except those where If there are no adjacent elements of the same character - do not print anything. What exactly does "not output" mean? So it is displayed on my screen only if there are at least two adjacent elements suitable for the conditions.