title: How can I validate user input to take only numbers
body: <p>I have two questions:</p>
  
  <ol>
  <li><p>How to display the largest and smallest number which accept 5 numbers from user input</p></li>
  <li><p>How can I validate user input to take only numbers.</p></li>
  </ol>
  
  <p>Here is my code :</p>
  
  <pre><code>input_set = list()
  num = input("Enter how many elements you want:")
  print("Enter numbers in array:")
  for i in range(int(num)):
      n = int(input("input number :"))
      input_set.append(int(n))
  print ("ARRAY: ", input_set)
  largest = input_set[0]
  for i in range(len(input_set)):
  
      if input_set[i] &gt; largest:
          greatest = input_set[i]
  
  print("Largest number is :", greatest)
  
  smallest = input_set[0]
  for i in range(len(input_set)):
  
      if input_set[i] &lt; largest:
          smallest = input_set[i]
  
  print("Smallest number is :", smallest)
  </code></pre>