title: Coursera - Python for everybody - ex 5.2
body: <p>For the following problem:<br>
  Write a program that repeatedly prompts a user for integer numbers until the user enters <code>done</code>.
  <br> Once 'done' is entered, print out the largest and smallest of the numbers. <br>
  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. <br>
  Input Cases: <br>
  Enter 7, 2, bob, 10, and 4 and match the output below.</p>
  <p>My program is not correctly showing the ans. What is problem here? <br></p>
  <pre><code>while True:
  inp = input(&quot;Enter number: &quot;)
  
  if inp == &quot;done&quot;:
      print(&quot;done&quot;)
      break
  try:
      inp_data = int(inp)
  except:
      print(&quot;Invalid input&quot;)
  if smallest is None:
      smallest = inp_data
  elif inp_data &lt; smallest:
      smallest = inp_data
  elif inp_data &gt; largest:
      largest = inp_data
      
  print(&quot;largest&quot;, largest)
  print(&quot;smallest&quot;, smallest)
  </code></pre>
  <blockquote>
  <p>Output:<br />
  Invalid input,
  Maximum is 10,
  Minimum is 2.</p>
  </blockquote>
  <p><a href="https://i.stack.imgur.com/IDO3v.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IDO3v.png" alt="Output of the program" /></a></p>