How to print this pattern?

Text: Apple
AppleApple
ppleAppl
pleApp
leAp
eA

It’s a pattern that removes the first and last character of a string being doubled.
I have tried a code but it’s wrong.

t=input('Text: ')
t=list(t)
t1=t+t
for w in t1:
    print(w,end='')
    t1.remove(t1[0])
    t1.remove(t1[-1])
    print(w,end='')

output:
AAppAAll
What’s wrong? Thanks

Here is what I would do:

text = input("Word: ")
double = text+text
print(double)
for letter in double:
    print(double[1:-1])
    double = double[1:-1]
1 Like

Thank you very much:grinning::grinning::grinning:

reverse a sring using recursive function
code not mine doesn’tt bellong to me

def reverse_recur(str):
if len(str) ==0:
return str
else:
return reverse_recur(str[1:]+str[0]

str = input(""ebter your string")
rev_str = reverse_recur(str)
print("Reverse your string:", rev_str)
1 Like

image

It works on my end. There is something wrong with your editor; it makes no sense for the 3rd line to print what it is. Have you tried through the cmd window?

1 Like

Nothing, sorry. Now it works. I just ran the wrong file. Thanks