def valid_sec(string):
    """Check if string is a valid IP address section"""
    if len(string) == 0:
        return False
    num = int(string)
    if string != str(num):
        # invalid string like "000" -- only one "0" is okay
        return False
    return num >= 0 and num <= 255