0

For example i have a string "mission", i want my program to print as below starting from the first letter.

mission issoinm ssionmi sionmis ionmiss onmissi nmissio

John Kugelman
  • 349,597
  • 67
  • 533
  • 578
Nani
  • 51
  • 3

1 Answers1

1

This code would give the exact output you're expecting.

def rotate(lst, n):
    return lst[-n:] + lst[:-n]

s = 'mission'

for i in range(len(s)):
    print(rotate(s,-i), end=' ')

Output:

mission issionm ssionmi sionmis ionmiss onmissi nmissio

The function for rotation was borrowed from this post.

Ébe Isaac
  • 11,563
  • 17
  • 64
  • 97