code: def strip_ip_port(ip_address):
      
  
      # IPv4 with or without port
      if '.' in ip_address:
          cleaned_ip = ip_address.split(':')[0]
  
      # IPv6 with port
      elif ']:' in ip_address:
          # Remove the port following last ':', and then strip first and last chars for [].
          cleaned_ip = ip_address.rpartition(':')[0][1:-1]
  
      # IPv6 without port
      else:
          cleaned_ip = ip_address
  
      return cleaned_ip
docs: Strips the port from an IPv4 or IPv6 address, returns a unicode object.