Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. filename = input("Enter filename: ")
  2.  
  3. with open(filename, "r") as f:
  4. the_file = f
  5. with open("sentences.txt", "w+") as w:
  6. string_of_words = ""
  7. for word in the_file:
  8. word = word.strip()
  9. if word == ".":
  10. string_of_words += "."
  11. print(string_of_words)
  12. print(string_of_words, file=w)
  13. string_of_words = ""
  14. else:
  15. if string_of_words != "":
  16. if word == ",":
  17. string_of_words += ','
  18. else:
  19. string_of_words += " " + word
  20. else:
  21. string_of_words += word
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement