文字列を順番に入れ替えする。
rolling.py
word = "abcde"
def rolling(str , n):
return str[n:len(str)] + str[:n]
for i in range(len(word)):
print(rolling(word,i))
# abcde
# bcdea
# cdeab
# deabc
# eabcd
Go to list of users who liked
Share on X(Twitter)
Share on Facebook
More than 5 years have passed since last update.
文字列を順番に入れ替えする。
word = "abcde"
def rolling(str , n):
return str[n:len(str)] + str[:n]
for i in range(len(word)):
print(rolling(word,i))
# abcde
# bcdea
# cdeab
# deabc
# eabcd
Register as a new user and use Qiita more conveniently
Go to list of users who liked