Question 8
Back to Exercise
What is the output of the following Python program?
s = " the sky is blue "
print(repr(" ".join(s.split()[::-1])), repr(s.strip()[::-1][:4]))
- A 'blue is sky the' 'eulb'
- B 'eulb si yks eht' 'eulb'
- C 'blue is sky the' 'eulb' Correct
- D 'blue is sky the' ' eul'
Correct Answer: Option C
split() drops extra spaces, so the reversed words are joined with single spaces. strip() removes the trailing space before reversing the characters.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!