code: def _user_submitted_barcode(max_length):
      '''
      User can enter a serial number as a string of HEX values
      Length of byte array must equal `num`
      '''
      barcode = input('BUTTON + SCAN: ').strip()
      if len(barcode) > max_length:
          raise Exception(BAD_BARCODE_MESSAGE.format(barcode))
      # remove all characters before the letter P
      # for example, remove ASCII selector code "\x1b(B" on chinese keyboards
      barcode = barcode[barcode.index('P'):]
      barcode = barcode.split('\r')[0].split('\n')[0]  # remove any newlines
      return barcodf _user_submitted_barcode(max_length):
      '''
      User can enter a serial number as a string of HEX values
      Length of byte array must equal `num`
      '''
      barcode = input('BUTTON + SCAN: ').strip()
      if len(barcode) > max_length:
          raise Exception(BAD_BARCODE_MESSAGE.format(barcode))
      # remove all characters before the letter P
      # for example, remove ASCII selector code "\x1b(B" on chinese keyboards
      barcode = barcode[barcode.index('P'):]
      barcode = barcode.split('\r')[0].split('\n')[0]  # remove any newlines
      return barcode
docs: User can enter a serial number as a string of HEX values
      Length of byte array must equal `num`