import socket

target = input("Enter the target IP address")
portRange = input("Enter the port range [eg: 1-100]")

lowPort = int(portRange.split('-')[0])
highPort = int(portRange.split('-')[1])

for port in range(lowPort, highPort):
    s = socket.socket(socket.AF_INET , socket.SOCK_STREAM)
    status = s.connect_ex((target, port))
    if (status == 0) :
        print("*** Port ", port, " Open ***")
    else:
        print("Port ", port, "Closed")
    s.close()