Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # palindroms
- word = input()
- length = len(word)
- mid = ""
- word1 = list(word[:length // 2])
- if length % 2:
- word2 = list(word[length // 2 + 1:][::-1])
- mid = word[length // 2]
- if mid == "?":
- mid = "0"
- else:
- word2 = list(word[length // 2:][::-1])
- for index in range(length // 2):
- if word1[index] == "?":
- if word2[index] == "?":
- word1[index], word2[index] = "0", "0"
- else:
- word1[index] = word2[index]
- else:
- if word2[index] == "?":
- word2[index] = word1[index]
- if word1 != word2:
- print("NO SOLUTION")
- else:
- print("".join(word1) + mid + "".join(word2))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement