def checkCAS(CASRN):
try:<EOL><INDENT>check = CASRN[-<NUM_LIT:1>]<EOL>CASRN = CASRN[::-<NUM_LIT:1>][<NUM_LIT:1>:]<EOL>productsum = <NUM_LIT:0><EOL>i = <NUM_LIT:1><EOL>for num in CASRN:<EOL><INDENT>if num == '<STR_LIT:->':<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>productsum += i*int(num)<EOL>i += <NUM_LIT:1><EOL><DEDENT><DEDENT>return (productsum % <NUM_LIT:10> == int(check))<EOL><DEDENT>except:<EOL><INDENT>return False<EOL><DEDENT>
Checks if a CAS number is valid. Returns False if the parser cannot 
    parse the given string..

    Parameters
    ----------
    CASRN : string
        A three-piece, dash-separated set of numbers

    Returns
    -------
    result : bool
        Boolean value if CASRN was valid. If parsing fails, return False also.

    Notes
    -----
    Check method is according to Chemical Abstract Society. However, no lookup
    to their service is performed; therefore, this function cannot detect
    false positives.

    Function also does not support additional separators, apart from '-'.

    CAS numbers up to the series 1 XXX XXX-XX-X are now being issued.

    A long can hold CAS numbers up to 2 147 483-64-7

    Examples
    --------
    >>> checkCAS('7732-18-5')
    True
    >>> checkCAS('77332-18-5')
    False