I think it will work:
name = input("Put in a name: ")
for i in range(len(name)): # for 1st half
print(name[i:])
for i in range(len(name)-2,-1,-1): # for 2nd half
print(name[i:])
Input:
stack
Output:
stack
tack
ack
ck
k
ck
ack
tack
stack
I Split output into two halfs:
1st half:
stack
tack
ack
ck
k
Which will be achieved by 1st for
loop using Slice (check to understand more Explain Python's slice notation)
And 2nd half:
ck
ack
tack
stack
Note: You can print single character in this example k
in 1st for
loop like i do or in 2nd for
loop, it up to you.
Hope this helps.
Although I think you should use solution suggested by @Andrew it's pretty cool if you print a
in his solution you get the sequence [0, 1, 2, 3, 4, 3, 2, 1, 0]
for slice the string so can be done in single for
loop