title: How do I check if input is a number in Python?
body: <p>I have a Python script which converts a decimal number into a binary one and this obviously uses their input.</p>
  
  <p>I would like to have the script validate that the input is a number and not anything else which will stop the script.</p>
  
  <p>I have tried an if/else statement but I don't really know how to go about it. I have tried <code>if decimal.isint():</code> and <code>if decimal.isalpha():</code> but they just throw up errors when I enter a string.</p>
  
  <pre><code>print("Welcome to the Decimal to Binary converter!")
  while True:
      print("Type a decimal number you wish to convert:")
      decimal = int(input())
      if decimal.isint():
          binary = bin(decimal)[2:]
          print(binary)
      else:
          print("Please enter a number.")
  </code></pre>
  
  <p>Without the if/else statement, the code works just fine and does its job.</p>