Read the question, write Python on the right, then Run or Check.
QuestionHint and solution stay closed until you open them
Read two integers (one per line) and print them swapped: the second, then the first.
Python tuple unpacking makes the swap a one-liner: a, b = b, a.
Input. Two lines, each one integer.
Output. Two integers: b then a, space-separated.
Examples
Input
3 5
Output
5 3
Input
0 -1
Output
-1 0
Hint
- a, b = b, a swaps without a temp variable.
- print(b, a) also works — try the unpack so you see the idiom.
Show correct code
Peek only after you have tried. You can still Check your own version.
a = int(input())
b = int(input())
a, b = b, a
print(a, b)
main.pyPython · Ctrl + Enter runs
ResultIdle
Run to see output. Check grades the tests.