title: How to check if a user input is a float
body: <p> I'm doing Learn Python the Hard Way exercise 35. Below is the original code, and we're asked to change it so it can accept numbers that don't have just 0 and 1 in them.</p>
  
  <pre class="lang-python prettyprint-override"><code>def gold_room():
      print "This room is full of gold. How much do you take?"
  
      next = raw_input("&gt; ")
  
      if "0" in next or "1" in next:
          how_much = int(next)
  
      else:
          dead("Man, learn to type a number.")
  
      if how_much &lt; 50:
          print "Nice, you're not greedy, you win!"
          exit(0)
  
      else:
          dead("You greedy bastard!")
  </code></pre>
  
  <p>This is my solution, which runs fine and recognizes float values:</p>
  
  <pre class="lang-python prettyprint-override"><code>def gold_room():
      print "This room is full of gold. What percent of it do you take?"
  
      next = raw_input("&gt; ")
  
      try:
          how_much = float(next)
      except ValueError:
          print "Man, learn to type a number."
          gold_room()
  
      if how_much &lt;= 50:
          print "Nice, you're not greedy, you win!"
          exit(0)
  
      else:
          dead("You greedy bastard!")
  </code></pre>
  
  <p>Searching through similar questions, I found some answers that helped me write another solution, shown in the below code. The problem is, using isdigit() doesn't let the user put in a float value. So if the user said they want to take 50.5%, it would tell them to learn how to type a number. It works otherwise for integers. How can I get around this?</p>
  
  <pre class="lang-python prettyprint-override"><code>def gold_room():
      print "This room is full of gold. What percent of it do you take?"
  
      next = raw_input("&gt; ")
  
  while True:
      if next.isdigit():
          how_much = float(next)
  
          if how_much &lt;= 50:
              print "Nice, you're not greedy, you win!"
              exit(0)
  
          else:
              dead("You greedy bastard!")
  
      else: 
          print "Man, learn to type a number."
          gold_room()
  </code></pre>