''' Purpose: find the word of the longest length amongst the input ''' # get the words reply = input( "Enter a series of words: " ) words = reply.split() # need to keep track of the longest word seen so far. It's initialization # should never prevent a word of longest length being missed longest_word_seen_so_far = '' # The longest word starts off as an empty string # We replace this variable (accumulator) each time we find a longer word # consider the words one by one for word in words : nw = len( word ) # Get the length of the word we're currently on (current word) nl = len( longest_word_seen_so_far ) print('word = ', word, 'longest word seen so far = ', longest_word_seen_so_far) # Check if the length of the word is longer than the longest_seen_so_far if ( nw > nl ): # If the length of the word we're on is longer than the longest word longest_word_seen_so_far = word # The longest_word_seen_so_far is now the word we're on! (the current word) else: continue # go to the next value of the loop variable in the loop # pass # do nothing # break # get out of the loop (pls be careful with this one and # like know what you're doing if you use this one plsplspls) # You don't need an else: pass # check the word out - compare its length to longest so far # if current word is longer than the longest word so far, need to update ... # longest word so far must be longest as considered every word as a possibility # print longest word ...