Swap two numbers
Input
swap_values(1, 2)
Output
(2, 1)
Values 1 and 2 are swapped and returned.
Full lesson preview
Swap the values of two variables using Python's tuple unpacking without a temporary variable.
Problem statement
Task
Examples
Input
swap_values(1, 2)
Output
(2, 1)
Values 1 and 2 are swapped and returned.
Input format
Output format
Constraints
Samples
Input
swap_values('x', 'y')
Output
('y', 'x')
String values are swapped and returned.