''' Purpose: spell check a line of input ''' # import get module for url supoprt import url # define link for spelling dictionary WORDS_FOLDER_URL = "http://www.cs.virginia.edu/~cs1112/datasets/words/" SPELLING_LIST_URL = WORDS_FOLDER_URL + "most-common" # SPECIFIC TEXT FILE # get the spelling list as a list of words text = url.get_contents( SPELLING_LIST_URL ) # GET TEXT ON PAGE spellings = text.split() # GET A LIST OF WORDS (CORRECTLY SPELLED WORDS) # get the user text as a list of words reply = input( "Enter text: " ) reply = reply.lower() # Make all text lowercase words = reply.split() # Have a list of lowercase words to compare each # word to see if it's in our list of correctly spelled # words! # consider the words one by one -- determine whether current word is misspelled. for word in words: if( word not in spellings ): # If the word isn't in list of correct words print( word) # Print it out! It's misspelled! # Is the word misspelled? How can I test if each word's in our # list of correctly spelled words?? USE NOT IN # !!!(Remember we have in and not in to see if an element is in a list) # If it's misspelled it's not going to be in our list # of correctly spelled words sooo we'll print it out. # all done