word = input("Word: ")
for n in range(0, len(word)):
sliced_front = word.replace(word[n:], '')
sliced_back = word.replace(word[:n+1], '')
print(sliced_front, sliced_back)
In above code, if I enter 'breatd', this is the output:
reatd
b eatd
br atd
bre td
brea d
breat
If I enter 'states', this is the output:
tate
s ates
st tes
sta es
stat s
tate
If I enter 'events', this is the output:
vnts
e ents
ev nts
eve ts
even s
event
Why does python remove 's' twice in the first and last iterations when the input is 'states', while removing 'e' twice only in the first iteration, not in third iteration when input is 'events'?
I want to remove a single character in each iteration. How can I make this stop removing the repeated character twice in a single iteration?