import re
strings = [
"python...is...fun...",
"python...is...fun",
"python...is...fun??"
]
for s in strings:
new_text = re.sub(r"(?:\.{2,}|(?<!\.))$", ".", s)
print(new_text)
aW1wb3J0IHJlIApzdHJpbmdzID0gWwoJInB5dGhvbi4uLmlzLi4uZnVuLi4uIiwKCSJweXRob24uLi5pcy4uLmZ1biIsCgkicHl0aG9uLi4uaXMuLi5mdW4/PyIKXQoKZm9yIHMgaW4gc3RyaW5nczoKCW5ld190ZXh0ID0gcmUuc3ViKHIiKD86XC57Mix9fCg/PCFcLikpJCIsICIuIiwgcykKCXByaW50KG5ld190ZXh0KQ==