parameters: (barcode)
return_statement: return dsum == int(barcode[11])
docstring: Check weather the UPC-A barcode was decoded correctly.
  
    This function calculates the check digit of the provided barcode and compares
    it to the check digit that was decoded.
  
    Args:
      barcode(string): The barcode (12-digit).
    Return:
      (bool): True if the barcode was decoded correctly.
docstring_summary: Check weather the UPC-A barcode was decoded correctly.
docstring_tokens: Check weather the UPC - A barcode was decoded correctly .
function: def _check_barcode(barcode):
    """Check weather the UPC-A barcode was decoded correctly.
  
    This function calculates the check digit of the provided barcode and compares
    it to the check digit that was decoded.
  
    Args:
      barcode(string): The barcode (12-digit).
    Return:
      (bool): True if the barcode was decoded correctly.
    """
    if len(barcode) != 12:
      return False
  
    r1 = range(0, 11, 2)  # Odd digits
    r2 = range(1, 10, 2)  # Even digits except last
    dsum = 0
    # Sum all the even digits
    for i in r1:
      dsum += int(barcode[i])
    # Multiply the sum by 3
    dsum *= 3
    # Add all the even digits except the check digit (12th digit)
    for i in r2:
      dsum += int(barcode[i])
    # Get the modulo 10
    dsum = dsum % 10
    # If not 0 substract from 10
    if dsum != 0:
      dsum = 10 - dsum
    # Compare result and check digit
    return dsum == int(barcode[11])
function_tokens: def _check_barcode ( barcode ) : if len ( barcode ) != 12 : return False r1 = range ( 0 , 11 , 2 ) # Odd digits r2 = range ( 1 , 10 , 2 ) # Even digits except last dsum = 0 # Sum all the even digits for i in r1 : dsum += int ( barcode [ i ] ) # Multiply the sum by 3 dsum *= 3 # Add all the even digits except the check digit (12th digit) for i in r2 : dsum += int ( barcode [ i ] ) # Get the modulo 10 dsum = dsum % 10 # If not 0 substract from 10 if dsum != 0 : dsum = 10 - dsum # Compare result and check digit return dsum == int ( barcode [ 11 ] )