Question #195937

Reverse Alternate Words in Sentence

Given a sentence, write a program to reverse the alternate words in the sentence and print it.


Reverse the first word and respective alternative words.

Input

The input will be a single line containing a sentence.

Output

The output should be a single line containing the sentence with the alternate words reversed.

Explanation

For example, if the given sentence is

Sun rises in the east and sets in the west The alternate words which need to be reversed are (Sun, in, east, sets, the), by reversing these words the output should be nuS rises ni the tsae and stes in eht west


Sample Input 1

Sun rises in the east and sets in the west


Sample Output 1

nuS rises ni the tsae and stes in eht west


Sample Input 2

The car turned the corner


Sample Output 2

ehT car denrut the renroc




Expert's answer

lst = input().split()
for index in range(0, len(lst), 2):
    lst[index] = lst[index][::-1]
print(' '.join(lst))
LATEST TUTORIALS
APPROVED BY CLIENTS