Interview Query

Swap Variables

Start Timer

0:00:00

Upvote
6
Downvote
Save question
Mark as completed
View comments (9)
Next question

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}
.
.
.
.
.


Comments

Loading comments.