Answer to Question #320744 in Python for sandhya

Question #320744

Find the password:

Joey is planning 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 it's w words in the right.Can you help joey find the password

input:

The input is a string G

The second line input is integer w

i/p:

Raju is going to school

3

o/p:

going to school Raju is

i/p: Trapezium order pattern

1

o/p: pattern Trapezium order


1
Expert's answer
2022-04-01T02:10:16-0400
str = input("Enter string: ").split()
n = int(input("Number of rotations (w): "))
for _ in range(n):
    temp = str[len(str)-1]
    for i in range(len(str)-1, 0, -1):
        str[i] = str[i-1]
    str[0] = temp
print()
print("Output:")
for i in range(len(str)):
    print(str[i], end=' ')

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