code: def fetch_country_by_ip(ip):
      
      iplookup = ipdata.ipdata()
      data = iplookup.lookup(ip)
      if data.get('status') != 200:
          return ''
  
      return data.get('response', {}).get('country_code', '')
docs: Fetches country code by IP
  
      Returns empty string if the request fails in non-200 code.
  
      Uses the ipdata.co service which has the following rules:
  
      * Max 1500 requests per day
  
      See: https://ipdata.co/docs.html#python-library