import urllib.request # where should we obtain data from? url = "http://cims.nyu.edu/~kapp/python/most_popular_words_in_english.txt" # attempt to access www.nyu.edu try: # initiate request to URL response = urllib.request.urlopen(url) # read data from URL as a String, making sure # that the String is formatted as a series of ASCII characters data = response.read().decode('utf-8') # an error occurred! handle it here except: print ("Something went wrong!") # if we made it past the except, then everything went as planned # let's split our data into a list split_data = data.split("\n") # get the user to pick a word word = input("What word would you like me to search for?") # determine if user's word is in our list or not if word in split_data: print("Your word is one of the 100 most popular words!") else: print("Sorry, your word is not one of the most popular words.")