Skip to main content
added 187 characters in body
Source Link

You first need to define what is a sentence for you. On this case, a sentence is separeted by '.', so you just need to imput:

a = "First sentence. Second. Third." print(a.replace(". ", ".\n"))

But if you will consider others caracteres, like '!', '?' and ';', you will also put those options too.

All code:

f = open("demofile.txt", "r")
print(f.read())

a = f.read()
print(a.replace(". ", ".\n"))

f = open("demofile2.txt", "a")
f.write(a.replace(". ", ".\n"))

You first need to define what is a sentence for you. On this case, a sentence is separeted by '.', so you just need to imput:

a = "First sentence. Second. Third." print(a.replace(". ", ".\n"))

But if you will consider others caracteres, like '!', '?' and ';', you will also put those options too.

You first need to define what is a sentence for you. On this case, a sentence is separeted by '.', so you just need to imput:

a = "First sentence. Second. Third." print(a.replace(". ", ".\n"))

But if you will consider others caracteres, like '!', '?' and ';', you will also put those options too.

All code:

f = open("demofile.txt", "r")
print(f.read())

a = f.read()
print(a.replace(". ", ".\n"))

f = open("demofile2.txt", "a")
f.write(a.replace(". ", ".\n"))
Source Link

You first need to define what is a sentence for you. On this case, a sentence is separeted by '.', so you just need to imput:

a = "First sentence. Second. Third." print(a.replace(". ", ".\n"))

But if you will consider others caracteres, like '!', '?' and ';', you will also put those options too.