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
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=' ')
Comments
Leave a comment