Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- import sys
- # opening file
- #f = open("astronomy.txt", "r") # uncomment if not using command line for run script
- words = list()
- # iterating through lines in corpus, breaking into lines, filling "words" list with lines from corpus
- for token in sys.stdin:
- token = token.strip()
- words.append(token)
- # randomly choosing a line from source corpus
- selection = random.choice(words)
- # assigning variables with both pre-determined and dynamic string values
- first = "Then, "
- middle = str(selection)
- last = ". Just like today."
- print first + middle + last
- # closing file
- #f.close() # unncomment for non-command line use cases
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement