Answer to Question #302721 in Python for Rahul

Question #302721

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


1
Expert's answer
2022-02-28T01:04:23-0500
G = input('Enter the string: ')
W = int(input('Enter the integer: '))-1
print(" ".join(G.split(' ')[W:]+G.split(' ')[:W]))

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS