python 3.x - How to rotate and print all the characters of a string in python3 starting from every character of the string? -
for example have string "mission", want program print below starting first letter.
mission issoinm ssionmi sionmis ionmiss onmissi nmissio
this code give exact output you're expecting.
def rotate(lst, n): return lst[-n:] + lst[:-n] s = 'mission' in range(len(s)): print(rotate(s,-i), end=' ')
output:
mission issionm ssionmi sionmis ionmiss onmissi nmissio
the function rotation borrowed this post.
Comments
Post a Comment