import ipaddress def main(ip: str) : mask = [31, 30, 29, 28, 27, 26, 25, 24] for i in mask: net = ipaddress.ip_network(f'{ip}/{i}', strict=False) print(net) # Press the green button in the gutter to run the script. if __name__ == '__main__': main('192.168.11.144') # See PyCharm help at https://www.jetbrains.com/help/pycharm/