text = input("Введите текст: ")
punctuation_marks = [".", ",", "!", "?"]result = ""
for i in range(len(text)-1):result += text[i]if text[i] in punctuation_marks and text[i+1] != " ":result += " "
result += text[-1]
print("Результат:", result)
text = input("Введите текст: ")
punctuation_marks = [".", ",", "!", "?"]
result = ""
for i in range(len(text)-1):
result += text[i]
if text[i] in punctuation_marks and text[i+1] != " ":
result += " "
result += text[-1]
print("Результат:", result)