def NonNegativeInt(n):
if not isinstance(n, str):<EOL><INDENT>raise ValueError('<STR_LIT>' % n)<EOL><DEDENT>try:<EOL><INDENT>n = int(n)<EOL><DEDENT>except:<EOL><INDENT>raise ValueError('<STR_LIT>' % n)<EOL><DEDENT>if n < <NUM_LIT:0>:<EOL><INDENT>raise ValueError('<STR_LIT>' % n)<EOL><DEDENT>else:<EOL><INDENT>return n<EOL><DEDENT>
If *n* is non-negative integer returns it, otherwise an error.

    >>> print("%d" % NonNegativeInt('8'))
    8

    >>> NonNegativeInt('8.1')
    Traceback (most recent call last):
       ...
    ValueError: 8.1 is not an integer

    >>> print("%d" % NonNegativeInt('0'))
    0

    >>> NonNegativeInt('-1')
    Traceback (most recent call last):
       ...
    ValueError: -1 is not non-negative