def fun(S):
while S.find(" ,")>=0: S = S.replace(" ,", ",")
while S.find(" .")>=0: S = S.replace(" .", ".")
S = S.replace(",", ", ")
S = S.replace(".", ". ")
while S.find(" ")>=0: S = S.replace(" ", " ")
return S
st = input("Введите строку: ")
print(fun(st))
Пример:
Введите строку: маша , петя .даша ,коля.света .
маша, петя. даша, коля. света.
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Verified answer
def fun(S):
while S.find(" ,")>=0: S = S.replace(" ,", ",")
while S.find(" .")>=0: S = S.replace(" .", ".")
S = S.replace(",", ", ")
S = S.replace(".", ". ")
while S.find(" ")>=0: S = S.replace(" ", " ")
return S
st = input("Введите строку: ")
print(fun(st))
Пример:
Введите строку: маша , петя .даша ,коля.света .
маша, петя. даша, коля. света.