I am wondering why my for loop is not updating the old_hosts values and why is updating the workers in the following code? I am NOT assigning any new value to the workers variable!!!
workers = [['w1', 1],['w2',2]]
old_hosts = [['w1',-1],['w1',-11]]
for old_host in old_hosts:
old_host = [*(worker for worker in workers if worker[0]==old_host[0])][0]
old_host[1]= 3
print('old_host: ' + str(old_host))
print('workers: ' + str(workers))
print('old_hosts: ' + str(old_hosts))
output:
old_host: ['w1', 1]
old_host: ['w1', 1]
workers: [['w1', 3], ['w2', 2]]
old_hosts: [['w1', -1], ['w1', -11]]