I am looking to make a portion of an application where the user inputs their domain and the IP addresses is resolved. If socket.gethostbyname doesn't return a result i.e. comes back with socket.gaierror: [Errno 8] nodename nor servname provided, or not known: I want to loop the input function so as the user is asked to input again until a valid result is returned for resolvedip. I have used while loops and a manner of things but can't seem to get the result I am after.
What would I need to add to the code below to achieve this ?
nsip = input("\nEnter your target website [example: google.com] : ")
resolvedip = socket.gethostbyname(nsip)#
print(resolvedip)