''' Purpose: find the words of maximum length in user text ''' # get the words reply = input( 'Enter text: ' ) words = reply.split() # consider the words one by one to find a longest word longest_seen = "" # so far nothing has been seen for word in words : # consider each word in turn nw = len( word ) # get its length nl = len( longest_seen ) # get the length of the longest seen so far if ( nl < nw ) : # compare the two lengths longest_seen = word # if current word is longer, update longest seen # determine the words of longest length longest_words = [] ... # print result print( longest_words )