+ 4

how to write code for this in Python.. please help me

faded palindrome or smallest palindrome Given a string S having characters from English alphabets ['a' - 'z'] and '.' as the special character (without quotes).  Write a program to construct the lexicographically smallest palindrome by filling each of the faded character ('.') with a lower case alphabet. Definition: The smallest lexicographical order is an order relation where string s is smaller than t, given the first character of s (s1 ) is smaller than the first character of t (t1), or in case they are equivalent, the second character, etc. For example "aaabbb" is smaller than "aaac" because although the first three characters are equal, the fourth character b is smaller than the fourth character c.  Input Format:  String S Output Format:  Print lexicographically smallest palindrome after filling each '.' character, if it possible to construct one. Print -1 otherwise.

30th Sep 2018, 5:14 PM
Sujithra
3 Answers
+ 4
Hey, please check this possible solution: https://code.sololearn.com/czN2vHPU6myq/#py
30th Sep 2018, 7:38 PM
P.W.R.
P.W.R. - avatar
+ 2
that is right i am also thinking how can i do this but now it is easy for me
21st Apr 2019, 5:45 AM
Amogh Mittal
Amogh Mittal - avatar
0
a=input() l=len(a) if a[0]!=a[l-1]: print("-1",end="") else: for i in range(l): if a[i]==".": if a[(l-1)-i]!=".": print(a.replace(".",a[(l-1)-i]),end="") break else: print(a.replace(".","a"),end="") break
20th Oct 2019, 6:15 AM
Diksha Deb
Diksha Deb - avatar