Mar-08-2019, 07:30 AM
Hi,
I am trying to force the user enter IP format with below code. However, it does not work. User should be enter x.x.x.x/y format for IP to continue.
What is problem on below code?
thanks
I am trying to force the user enter IP format with below code. However, it does not work. User should be enter x.x.x.x/y format for IP to continue.
What is problem on below code?
thanks
def test(): while True: val = raw_input("enter IP:") try: IP=ipaddress.ip_network(str(val),True) except: if val == "": print " Enter subnet:" else: print " IP should be formatted X.X.X.X/Y" test()