[Solved] How to catch all the iteration of a “for” loop in a list?


If you want to get the results of every iterations of a for loop into a list, you need a list to store the values at each iteration.

import ipaddress
user_input = input("")
network = ipaddress.IPv4Network(user_input)

ipaddresses = [] #initiate an empty list

for i in network.hosts():
    ipaddresses.append(i)
print(ipaddresses)

solved How to catch all the iteration of a “for” loop in a list?