title: Print largest and smallest number in python
body: <p>I am trying to write a program that repeatedly prompts a user for integer numbers until the user enters 'done'. Once 'done' is entered, print out the largest and smallest of the numbers. If the user enters anything other than a valid number catch it with a try/except and put out an appropriate message and ignore the number. </p>
  
  <p>I am having problem in printing the largest and smallest number. Its printing incorrect number by the approach below:</p>
  
  <pre><code>largest = None
  smallest = None
  list1 = []
  while True:
      num = input("Enter a number: ")
      if num == "done" : break
      try:
          val = int(num)
          if int(num):
              list1.append(num)
      except:
          print("Invalid input") 
  print("Maximum is " + max(list1))
  print("Minimum is " + min(list1))
  </code></pre>
  
  <p>I am entering numbers as 7, 2, bob, 10, and 4.</p>
  
  <p>Its printing output as: 
  Invalid input
  Maximum is 7 
  Minimum is 10</p>
  
  <p>While the output I am looking for is:
  Invalid input
  Maximum is 10
  Minimum is 2</p>