Move M Words - End Reverse
Coding Problem Keys
Move M Words - End Reverse
Problem Statement
The program must accept a string S which contains N words and move the
first M words to the last in the reverse order.
Input Format
The first line contains S.
Output Format
The first line contains first M words to the last in the reverse
order.
Boundary Conditions
M <= N < 50.
10 <= Length of S <= 200.
Example Input/Output 1
Input
one two three four five
3
Output
four five three two one.
Note: Max Execution Time Limit: 5000 millisecs
Solution
Programming Language: Python 3 Language
z=list(map(str, input().split())) n=int(input()) z=z[n:]+z[:n][::-1] print(*z)
#Published By PKJCODERS (Note: Incase If the code doesn't Pass the output kindly comment us with your feedback to help us improvise.)
Comments