In python you can define a for loop without a variable and still access the contents of that. For example:
x = [1,2,3]
for _ in x: print (_)
will provide you an output of:
1
2
3
You can also do this with dictionaries. For example:
x = {1:10, 2:20}
for _,__ in x.items(): print (_,__)
The output of this will be:
1 10
2 20
In summary, you can use _ as a variable and reference it. While you may think there is no variable defined, it is still a throwaway variable. More details about _ can be found in this post: What is the purpose of the single underscore "_" variable in Python?
Based on this, you can rewrite your code as follows:
for _ in NODES:
if i % 2 == 0:
tex_pairs_to_swap_dict[NODES[i]] = NODES[i+1]
i += 1
With this, you don't need to use the variable node