Move each of three values one place to the left.
What to build
A program that changes what three variables hold.
Requirements
- Read
a,bandc. - Change them so that
aholds the oldb,bholds the oldc, andcholds the olda. - Print
a,bandcon one line, separated by spaces.
Input
Three lines, each with one word.
Output
One line with the three words in their new places.
Constraints
Each line holds exactly one word.
Example
Input:
x
y
z
Output:
y z x
Why it works
Python works out the whole right side first, so a, b, c = b, c, a sees all the old values at once. Doing it in separate lines would lose one of them.
Examples
Example 1 · Input
x y z
Expected output
y z x
Example 2 · Input
one two three
Expected output
two three one
Prompts inside input() are ignored when checking, so input("n: ") is fine.
Hints
Hint 1
You need all three values at once before you can move them.
Hint 2
a, b, c = b, c, a moves them in one line.
Solution
Show one correct solution (try it yourself first)
a = input() b = input() c = input() a, b, c = b, c, a print(a, b, c)