I'm trying to loop through 2 lists and combine the results and write that to a file, however I could find a method to do this yet.
hosts = ['host1', 'host2', 'host3']
ips = ['ip1', 'ip2', 'ip3']
filename = 'devicelist.txt'
with open(filename, 'w') as out_file:
for i in ips:
for h in hosts:
out_file.write(h + ' - ' + i + '\n')
This basically runs through every possible combination, but that's not the result I'm looking for. What I'm looking is like this:
host1 - ip1
host2 - ip2
host3 - ip3