Using a list as input to a function
I have a function that translates subnet IPs into IP ranges, but I need to input a list of subnets to this function and I am having trouble doing it:
My function at the moment:
import ipaddress
cidr = ["187.11.62.93,187.11.62.95"]
def get_ip_range(cidr):
net = ipaddress.ip_network(cidr)
return net[0], net[-1]
I also need the output in JSON but at the moment that is not a worry for me.
return[net[0],net[-1] for net[0],net[-1] in cidr]
I should have 2 IPs here, the lower and the upper IP of the range, but I am failing.
Comments
Post a Comment