Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- filename = input("Enter filename: ")
- with open(filename, "r") as f:
- the_file = f
- with open("sentences.txt", "w+") as w:
- string_of_words = ""
- for word in the_file:
- word = word.strip()
- if word == ".":
- string_of_words += "."
- print(string_of_words)
- print(string_of_words, file=w)
- string_of_words = ""
- else:
- if string_of_words != "":
- if word == ",":
- string_of_words += ','
- else:
- string_of_words += " " + word
- else:
- string_of_words += word
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement