# Freeman Lo # # Read a list of words from a text file, # randomly output one word on to a screen # and remove that word from the list after printing it. # # To demonstrate to students the power of python, # encourage coding to solve real life problems ########################################### import random def main(): #short cut r=random # file path and create file pointers path='.//words.txt' q=[] f=open(path) # insert words into the queue for i in f: q.append(i) # ask user to press enter or q to quit # this loop randomly selects a word from the list and prints it out # and the word from the queue after it has printed it out ans = raw_input("Enter any character to continue (press 'q' to quit ): ") while (ans != "q"): word = r.choice(q) print word q.remove(word) ans = raw_input("Enter any character to continue (press 'q' to quit ): ") main()