I am trying to use reduce as follows:
>>> reduce(lambda z,(x,y): (z+1) if x == y else z, [(3, 4), (5, 2), (4, 4), (5, 5)], 0)
In Python 2.7 I get the expected:
2
While the exact same line returns the following error in Python 3.5:
File "<stdin>", line 1
reduce(lambda z,(x,y): (z+1) if x == y else z, [(3, 4), (5, 2), (4, 4), (5, 5)], 0)
^
SyntaxError: invalid syntax
Any suggestions as to what the syntax should be for Python 3? Thanks.