Попробуйте вот так.
Может быть, это немного сложно.
Кажется, я восстановил верхнюю часть ( ) функция
import re
content="i have a long text that contains multiple paragraphs.\nit is stored in one variable.\ni need to uppercase the first letter every word that follows a line break (or a period).\nwhat is the most simple way to do that?"
def your_function_name(content):
new_res=[]
res=re.split(r'[.?\n]',content)
while "" in res:
res.remove("")
for con in res:
if 61<=ord(con[0])<=96:
new_con=con
new_res.append(new_con)
elif 97<=ord(con[0])<=123:
new_con=chr(ord(con[0])-32)+con[1:]
new_res.append(new_con)
else:
new_con=con
new_res.append(new_con)
return new_res
print("Transformed\n-----------------")
new_res=your_function_name(content)
for i in new_res:
print(i)
результаты следующие
Transformed
-----------------
I have a long text that contains multiple paragraphs
It is stored in one variable
I need to uppercase the first letter every word that follows a line break (or a period)
What is the most simple way to do that