def findClass(ip): if (ip[0]>=0 and ip[0]<=126): return "A" elif(ip[0]>=128 and ip[0]<=191): return "B" elif(ip[0]>=192 and ip[0]<=223): return "C" elif(ip[0]>=224 and ip[0]<=239): return "D" else: return "E" def separate (ip, className): if (className=="A"): print("Network address is : " , ip[0]) print("Host address is : ",".".join(ip[1:4])) elif(className=="B"): print("Network address is : ",".".join(ip[0:2])) print("Host address is : ",".".join(ip[2:4])) elif(className=="C"): print("network address is :" ,".".join(ip[1:3])) print("Host address is :" ,ip[3]) else : print("This ip cannot be divided in network and host