So, I am able to prompt the user for their IP address and check whether it is valid or not, but I cannot seem to figure out how to get this program to ask the user for another IP address if the one entered is invalid. Any help would be great!
import ipaddress
def validate_ip_address(address):
while True:
try:
ip = ipaddress.ip_address(address)
print("IP address {} is valid.".format(address, ip))
except ValueError:
print("IP address {} is not valid".format(address))
continue
else:
break
ip = input("Enter an ip: ")
validate_ip_address(ip)