M
M
MonsterAndrew2018-06-19 11:54:37
Python
MonsterAndrew, 2018-06-19 11:54:37

How many characters do you need to add to make a string a palindrome?

How can you use Python to find out what is the minimum number of characters that you need to assign to a string on the right or left so that it becomes a palindrome?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
longclaps, 2018-06-19
@MonsterAndrew

s = '1232'

for i in range(len(s)):
    t = s[:i] + s[::-1]
    if t == t[::-1]:
        print(i, t)
        break

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question