Basically I need help creating a function to read a given parameter which is a list, go through each digit of the list, checking them and adding their binary value to a different list. I am trying this code, but it's not working the way I think it should. Any help is welcome: The side parameter is there to help sort the binary. I have two sets and depending on which 'side' the digits in the list are on, they have a different binary code.
def bin_convert(upc, side):
    bin_list = []
    if side == 0:    
        for digit in upc:
            if digit == 0:
                bin_list.append(0001101)
            elif digit == 1:
                bin_list.append(0011001)
            elif digit == 2:
                bin_list.append(0010011)
            elif digit == 3:
                bin_list.append(0111101)
            elif digit == 4:
                bin_list.append(0100011)
            elif digit == 5:
                bin_list.append(0110001)
            elif digit == 6:
                bin_list.append(0101111)
            elif digit == 7:
                bin_list.append(0111011)
            elif digit == 8:
                bin_list.append(0110111)
            elif digit == 9:
                bin_list.append(0001011)
        print bin_list
        return bin_list
    else:    
        for digit in upc:
            if digit == 0:
                bin_list.append(1110010)
            elif digit == 1:
                bin_list.append(1100110)
            elif digit == 2:
                bin_list.append(1101100)
            elif digit == 3:
                bin_list.append(1000010)
            elif digit == 4:
                bin_list.append(1011100)
            elif digit == 5:
                bin_list.append(1001110)
            elif digit == 6:
                bin_list.append(1010000)
            elif digit == 7:
                bin_list.append(1000100)
            elif digit == 8:
                bin_list.append(1001000)
            elif digit == 9:
                bin_list.append(1110100)
        print bin_list
        return bin_list
 
    