import socket def dns_lookup(): choice = input("Choose an operation:\n1 -> lookup a URL\n2 -> lookup an IP address\nEnter choice (1/2):\t") if choice == '1': url = input("Enter the URL (e.g. kska.io): ") try: ip_address = socket.gethostbyname(url) print(f"The IP address for {url} is: {ip_address}") except socket.gaierror: print("Error: Unable to resolve the URL.") elif choice == '2': ip_address = input("Enter the IP address (e.g. 93.184.216.34): ") try: url = socket.gethostbyaddr(ip_address)[0] print(f"The URL for {ip_address} is: {url}") except socket.herror: print("Error: Unable to resolve the IP address.") else: print("Invalid choice. Please enter 1 or 2.") if __name__ == "__main__": dns_lookup()