title: Error handling that prompt the user to enter only integer greater than 1
body: <p>I am trying to write a Python function that asks for an input of integer greater than 1 and return or print the input value.</p>
  
  <p>For example when the code is being run:<br>
  <strong>Error case 1:</strong><br>
  Enter an integer greater than 1: 1<br>
  Output: Please enter a number greater than 1:</p>
  
  <p><strong>Error case 2:</strong><br>
  Enter an integer greater than 1: abc345<br>
  Output: Please enter integer values only:</p>
  
  <p>If it is just to handle error case 1, it is easy, we can just use the while loop. But to also include the case for non-integer input, my code always crashes.</p>
  
  <p>Here is my function:</p>
  
  <pre><code>    def mult_digits():
          x = input("Enter an integer greater than 1: ")    
          while type(x) is not int:
              try:
                  while int(x) &lt;= 1:
                      x = input("Please enter a number greater than 1: ")
                      x = int(x)
              except ValueError:
                    x = input("Please enter integer values only: ")
                    x = int(x)       
          print(f"Yes, you have entered {x}.")
  </code></pre>
  
  <p>The problem with my code is that int("a") will result in invalid literal for int() with base 10 error. Since the input() function always return a string and we need to check whether or not the string can be converted to integer, we need the int() function, but this is exactly where the problem is.</p>
  
  <p>I have tried many different variations of the code, including using for loop to scan the input value for any non-integer character, but it is not that efficient and still crashes. I have also tried a while loop that ended up creating an infinite loop.</p>
  
  <p>Could somebody please give some help? Is there any better way to write this function? I really appreciate it, thanks!</p>