0

I have two dictionaries:

worker_1 = {
"name": "Peter",
"age": 46,
"salary": 24098,
"city": "Washington"
}

worker_2 = {
"name": "Adam",
"age": 52,
"salary": 19894,
"city": "Colorado"
}

How can I change the values of these two workers so that the worker_1 gets the values of worker_2 and worker_2 gets the values of worker_1?

Thanks

Cory Kramer
  • 114,268
  • 16
  • 167
  • 218
Brijac
  • 27
  • 4

2 Answers2

4

Try this

worker_1, worker_2 = worker_2, worker_1
Emil
  • 87
  • 5
1
temp_worker = worker_1
worker_1 = worker_2
worker_2 = temp_worker

I would use a temporary variable because I like making sure there is no possibility of data loss or conflict.

mdign002
  • 89
  • 1
  • 1
  • 7