<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def int_to_charset(val, charset):
 """ Turn a non-negative integer into a string. '0' 'abcd' '10' 'muneeb.id' Traceback (most recent call last):
 ValueError: "val" must be a non-negative integer. """

    if val < 0:
        raise ValueError('"val" must be a non-negative integer.')

    if val == 0:
        return charset[0]

    output = ""
    while val > 0:
        val, digit = divmod(val, len(charset))
        output += charset[digit]

    # reverse the characters in the output and return
    return output[::-1]