>>> from functools import reduce >>> from operator import xor >>> bits = ('0', '1', '0', '1', '0', '1', '0') >>> reduce(xor, map(int, bits)) 1