easy +5 pts

Swap Two Values

Write a function that swaps the values of two variables and returns them.

Write a function named `swap_values` that takes two arguments, `a` and `b`, and returns a tuple of the two values in swapped order: `(b, a)`. The values can be of any type (e.g., integers, strings, lists). The function should not modify the original values; it should simply return them in the new order.

Constraints

The input can be any Python objects. The function must return a tuple containing the two values in swapped order. The function should work for any number of arguments (exactly two).

Example

>>> swap_values(1, 2)
(2, 1)
>>> swap_values('a', 'b')
('b', 'a')
>>> swap_values([1,2], [3,4])
([3,4], [1,2])
5 points ~5 min

Recent Submissions

No submissions yet — hit Run Tests to try!

Hints

You need to return a tuple with the second argument first and the first argument second.
The simplest solution is `return (b, a)`.
You do not need to use a temporary variable; Python's tuple unpacking is not required here.
Python 3
All tests passed!
Test Results
Press Ctrl+Enter or click Run Tests to execute your code.