Jan-26-2018, 08:17 PM
(This post was last modified: Jan-26-2018, 08:17 PM by goldtiger6.)
I'm working on a little code for class and I'm not sure what to do to make it print 0 when everything else is false.
Input:
P.S. Here is the problem:
Given a list of non-zero integers, find and print the first adjacent pair of elements that have the same sign. If there is no such pair, print 0.
Input:
1 -3 4 -2 1
a = [int(i) for i in input().split()] for i in range(1, len(a)): if a[i - 1] * a[i] > 0: print(a[i - 1], a[i]) breakOutput:
Output:No output (0 is expected)
I have no idea where to start to get that part working. P.S. Here is the problem:
Given a list of non-zero integers, find and print the first adjacent pair of elements that have the same sign. If there is no such pair, print 0.