Find the Password
Joey is playing escape room and to exit the room he has to find the password for the final door.To know the password he is given a sentence G and told to rearrange the sentence by rotating its W words in the right.Can you help joey find the password?
Input
The first line of input is a string G.
The second line of input is an integer W.
Output
The output is a string contains a sentence got by the rearrangement as per above mentioned criteria.
Explanation
In the above example, the sentence is Raju is going to school and W is 3.
Shift the three words in the right,which means the last three words will be moved to the front.
So, the output should be going to school Raju is
Sample Input1
Raju is going to school
3
Sample Output1
going to school Raju is
G = input('Enter the string: ')
W = int(input('Enter the integer: '))-1
print(" ".join(G.split(' ')[W:]+G.split(' ')[:W]))
Comments
Leave a comment