Suppose we have a string s of size n. We have to find all rotated strings by rotating them 1 place, 2 places ... n places.
So, if the input is like s = "hello", then the output will be ['elloh', 'llohe', 'lohel', 'ohell', 'hello']
To solve this, we will follow these steps −
Let us see the following implementation to get better understanding −
def solve(s): res =  n = len(s) for i in range(0, n): s = s[1:n]+s res.append(s) return res s = "hello" print(solve(s))
['elloh', 'llohe', 'lohel', 'ohell', 'hello']