SHARE
TWEET

Untitled

a guest Sep 19th, 2019 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top