Skip to content
Advertisement

Python – Move each character until end of string without reusing original string

I’m trying to move each character in a string, until the end of the string, and print each of those. But, without reusing the original string.

So say for the string “hello”, the result would be:

JavaScript

In the above example, the original string appear two times, even though i said “without reusing original string” but bear in mind it’s just there to illustrate the example better.

Here the code i made so far:

JavaScript

This succeed in moving character one by one until end of string, But, it does reuse the original string instead of doing it like in the above example…i couldn’t find a way to make it do what i want.

Advertisement

Answer

It is kind of like insertion sort. Do you like this answer?

JavaScript

output

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement