''' Purpose: demonstrate the printing of a list of words, one word per line ''' # get list of words reply = input( "Enter several words: " ) words = reply.split() # split reply into a list of words print( 'words =', words ) ### print the words word by word # we don't know how many words there are --> loop # IMPORTANT!! PLEASE REVIEW THIS!! # here our sequence is a LIST of words. Let words = [ 'word1', 'word2' ] # so our loop_variable ( w = stands for word ) will represent each WORD, NOT each character # what the loop variable represents depends on the TYPE OF SEQUENCE --> 3 kinds of for loops you have now learned # if sequence is a string, the loop variable represents each character in that string # if sequence is a list, the loop variable represents each element (separated by ,) in that list # if sequence is a range of numbers, the loop variable represents each number in the range # also loop variable can be named anything # words is NOT a string --> it's a LIST = sequence of THINGS # if sequence is a list, the loop variable takes on each of the THINGS one by one for w in words: # w is the current word; will go through each word inside the list of words # 1st time: w = 'word1' # 2nd time: w = 'word2' print( w )