def palindrome(sentence): if sentence[-1] == sentence[-2]: sentence2 = sentence[::-1] sentence3 = sentence2[2:] new_sentence = sentence + sentence3 print(new_sentence) else: sentence2 = sentence[::-1] sentence3 = sentence2[1:] new_sentence = sentence + sentence3 print(new_sentence) def check_palindrome(sentence): for i in range(len(sentence)): if sentence[i] == sentence[-(i + 1)]: pass else: palindrome(sentence) break else: print(sentence) sentence = input("") check_palindrome(sentence)