I have a list of 6 files and a list of 6 mac addresses. Each mac address corresponds to the file in the same list slot. For instance, mac_list[1]
corresponds to file_list[1]
, mac_list[2]
corresponds to file_list[2]
, etc. Each file already contains a mac address which is incorrect, so I need to overwrite the incorrect one with the new one (from mac_list
) which exists at the corresponding index in mac_list
. The actual replacement of each mac address I know how to do with sed. What I don't know how to do is only access the values which exist at the same index in both lists. My initial thought was to use a nested for loop for both lists and compare their indexes:
for addr in mac_list:
for file in file_list:
if addr.index == file.index:
#overwrite mac address
But is there a more efficient approach to this?