Benjamin Jones
Benjamin Jones

Reputation: 997

Python- IP address module

I have python 2.7 installed. I installed pip install py2-ipaddress. Ran the following in powershell. The issue is No Output

import ipaddress
def ipEntered():
    while True:
        try:
            val = input("Please enter the ip address of the server you wish to connect with:")
            return ipaddress.ip_address(val)
        except ValueError:
            print("Not a valid IP address")

Upvotes: 0

Views: 903

Answers (1)

Ashish Khatkar
Ashish Khatkar

Reputation: 104


The program runs fine. Can you share the example on which it is failing ? I used the following code to test it out.

import ipaddress
def ipEntered():
        while True:
                try:
                        val = raw_input()
                        return ipaddress.ip_address(val)
                except ValueError:
                        print ("Invalid")

print ipEntered()

Upvotes: 1

Related Questions