def to_hex_string(num, minDigits=0):
    """
    Helper function that converts a number to a 0 padded hex string

    >>> to_hex_string(5, 4)
    '0005'

    >>> to_hex_string(16)
    '10'

    >>> to_hex_string(20, 4)
    '0014'

    >>> to_hex_string(255)
    'FF'

    >>> to_hex_string([255, 255])
    'FFFF'

    >>> to_hex_string([1, 1])
    '0101'

    >>> to_hex_string([0, 0, 0])
    '000000'

    >>> to_hex_string(0, 4)
    '0000'
    """
    if isinstance(num, float):
        num = int(num)

    if isinstance(num, int):
        s = hex(num)[2:]
        if minDigits > len(s):
            s = "0" * (minDigits - len(s)) + s
        if s.endswith('L') or s.endswith('l'):
            s = s[:-1]
    else:
        s = "".join([to_hex_string(x, 2) for x in num])
        if minDigits > len(s):
            s = "0" * (minDigits - len(s)) + s
    return s.upper()