Help in ipaddress module

import ipaddress

MY_VPC_SUBNETS = [“”, “”, “”]
MY_SG_IPS = [“”, “”, “”, “”]

for network in MY_VPC_SUBNETS:
invalid_ips =
internal_network = ipaddress.ip_network(network)
for my_valid_ip in MY_SG_IPS:
my_ip = ipaddress.ip_network(my_valid_ip)
if not my_ip.subnet_of(internal_network):
print(my_ip, “in subnet”, internal_network)

So, I’m having some hard time finding the logic to finally tell me
“ip 60.x.x.x/y is not part of MY_VPC_SUBNETS”

Help for a Python Newbie pls !

Here’s a function that I used recently… assumed a /24 - change to whatever is desired.

 def check_ip(subnets, ip):
    # check if the ip is in any known subnet
    for network in enumerate(subnets):
        my_net = network[1][0] + "/24"
        net = IPv4Network(my_net)

        if IPv4Address(ip) in net:
            subnet = str(network[1][0]) + "/" + str(network[1][1])
            networkadrs = IPv4Network(subnet)
            print(f"{ip} is in {network[1][0]}/{network[1][1]} : {networkadrs}")
            return True
    return False