title: Python: How to print Shortest and Longest word in a text file?
body: <p>I'm trying to make my program print out the shortest and longest word found in a text file. Let's say I type "Pie is delicious" as my block of text. I then type EOF on a line by itself to end the input phase. I typed in option 1 to see the Shortest word and "is" should pop up, but I only get the letter "p" as my output. I get the same result for the second option, which is finding the Longest word, I end up getting the letter "p" when it should be "delicious." I'm using the min and max function to do this by the way.</p>
  
  <pre><code>#Prompt the user to enter a block of text.
  done = False
  textInput = ""
  while(done == False):
      nextInput= input()
      if nextInput== "EOF":
          break
      else:
          textInput += nextInput
  
  #Prompt the user to select an option from the Text Analyzer Menu.
  print("Welcome to the Text Analyzer Menu! Select an option by typing a number"
      "\n1. shortest word"
      "\n2. longest word"
      "\n3. most common word"
      "\n4. left-column secret message!"
      "\n5. fifth-words secret message!"
      "\n6. word count"
      "\n7. quit")
  
  #Set option to 0.
  option = 0
  
  #Use the 'while' to keep looping until the user types in Option 7.
  while option !=7:
      option = int(input())
  
      #Print out the shortest word found in the text.
      if option == 1:
          print(min(textInput, key = len))
  
      #Print out the longest word found in the text.
      elif option == 2:
          print(max(textInput, key = len))
  </code></pre>