''' Purpose: find the words of maximum length in user text ''' # get the words reply = input('Enter text: ') words = reply.split() # = is assignment, == is the equivalence test (relation) # <=, >= are also relation operators # consider the words one by one to find a shortest word shortest_seen = words[0] # so far nothing has been seen # Initialize it to the first word in the list and then # continue testing from there to see if you find anything shorter! # If you're trying to find the shortest, you can't # start with the empty string because nothing is shorter # than the empty string! for word in words: # consider each word in turn nw = len(word) # get its length ns = len(shortest_seen) # get the length of the shortest seen so far print('word = ', word, '| Shortest word seen so far = ', shortest_seen) if ( nw < ns ): # compare the two lengths shortest_seen = word # if current word is longer, update shortest seen print( shortest_seen ) # In general you can have as many test expressions in # your if statement as you want so you could do # a