Through this code, i wish to replace all the dots (.) appearing in the string s with the character present at exactly the symmetrically opposite position. For eg: if s=a.bcdcbba, then the . should be replaced by b
i.e:
The element at ith position should be replaced by the element at len(s)-i-1th position. This function gives wrong output for the cases like g.... , .g... etc. Any help ?
def replacedots(s):
for i in range(0,len(s)):
if s[i]==".":
s=s.replace(s[i],s[len(s)-i-1],1)
return s
"foo.bar"?s.replacedoesn't replace the dot atibut the first dot.