How can I set up data validation to restrict input for 3 fields to number only?
<p>I was just introducted to <code>python</code> a few days ago</p>

<p>I need user input for three different fields. How can I restrict user input to numbers for all three questions?</p>

<pre><code>while True:
    try:
        workinghours = int(raw_input("what is your working hours?"))
    except ValueError:
        print "Try again! what is your working hours?"
        continue

        normalrate = int(raw_input("what is your normal rate?"))
    except ValueError:
        print "Try again! what is your normal rate?"
        continue

        overtimerate = int(raw_input("what is your overtime rate"))
    except ValueError:
        print "Try again! what is your overtime rate?"
        continue

if workinghours &gt; 40:
    overworkinghours = workinghours - 40
    overtimepayment = overtimerate * overworkinghours
    print ("your extra overtime salary is + $%.2f" % overtimepayment)
    normalpayment = normalrate * 40
    print ("your normal hours salary is + $%.2f" % normalpayment)
    totalsalary = float(normalpayment) + float(overtimepayment)
    print ("your total salary is: + $%.2f" % totalsalary)
else:

    normalpayment = normalrate * workinghours
    print ("your total salary without overtime is $%.2f" % normalpayment)
</code></pre>

<h3>You're asking the poor soul the same information over and over again, no escape is possible :)</h3>

<p>Apart from the fact that the while loop never ends because there is no <code>break</code>statement anywhere, you are misunderstanding the <code>continue</code> statement. As we can read <a href="http://www.tutorialspoint.com/python/python_loop_control.htm" rel="nofollow">here</a>:</p>

<blockquote>
  <p>The continue statement in Python returns the control to the beginning of the while loop. The continue statement rejects all the remaining statements in the current iteration of the loop and moves the control back to the top of the loop.</p>
</blockquote>

<p>That means that if your user makes a mistake (wrong type of input), he returns to <em>the first question</em>, instead of the question he made the mistake in. </p>

<h3>Separate while loop foor each field</h3>

<p>You need to make it three separate <code>while</code> loops, one for each field:</p>

<pre><code>while True:
    try:
        workinghours = int(raw_input("what is your working hours? "))
    except ValueError:
        print "Try again! "
    else:
        break

while True:
    try:
        normalrate = int(raw_input("what is your normal rate? "))
    except ValueError:
        print "Try again! "
    else:
        break

while True:
    try:
        overtimerate = int(raw_input("what is your overtime rate? "))
    except ValueError:
        print "Try again! "
    else:
        break

if workinghours &gt; 40:
    overworkinghours = workinghours - 40
    overtimepayment = overtimerate * overworkinghours
    print ("your extra overtime salary is + $%.2f" % overtimepayment)
    normalpayment = normalrate * 40
    print ("your normal hours salary is + $%.2f" % normalpayment)
    totalsalary = float(normalpayment) + float(overtimepayment)
    print ("your total salary is: + $%.2f" % totalsalary)
else:
    normalpayment = normalrate * workinghours
    print ("your total salary without overtime is $%.2f" % normalpayment)
</code></pre>

python validation