Interview Query

Swap Variables

1
Have you seen this question before?

You are given a dictionary with two keys a and b that hold integers as their values.

Without declaring any other variable, swap the value of a with the value of b and vice versa.

Note: Return the dictionary after editing it.

Example:

Input:

numbers = {
  'a':3,
  'b':4
}

Output:

def swap_values(numbers) -> {'a':4,'b':3}
Next question: Third Party Ad Pricing
.....
Python 3.9.6
Loading editor
Use Shift + Enter to run code