Create a program that takes an IP address and print out the segment it contains.
Also, check if the format of the IP address is correct.
Also, check if the format of the IP address is correct.
def validate_ip(ip): ln = ip.split('.') if len(ln) != 4: return False for digit in ln: if not digit.isdigit(): return False i = int(digit) if i < 0 or i > 255: return False return True result = validate_ip(input("Please enter a IP address : ")) if result == True: print('Entered IP is correct') else: print('Invalid IP')
No comments:
Post a Comment