Perhaps you are looking at something like this:
arr = ['A','A','B','B','C','C','C']
def get_switched_array(in_array, value):
return [ 1 if v == value else 0 for v in in_array ]
print get_switched_array( arr, 'A')
print get_switched_array( arr, 'B')
print get_switched_array( arr, 'C')
which outputs:
[1, 1, 0, 0, 0, 0, 0]
[0, 0, 1, 1, 0, 0, 0]
[0, 0, 0, 0, 1, 1, 1]
source
share