<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def location(value):
 """ Transform an IP address into an approximate location. Example output: * Zwolle, The Netherlands * The Netherlands * None """

    try:
        location = geoip() and geoip().city(value)
    except Exception:
        try:
            location = geoip() and geoip().country(value)
        except Exception as e:
            warnings.warn(str(e))
            location = None
    if location and location['country_name']:
        if 'city' in location and location['city']:
            return '{}, {}'.format(location['city'], location['country_name'])
        return location['country_name']
    return None