Python while/try/if loop
<p>I'm just learning python and wanted to know if there's a better way to code this rather than using the try/except and if/else embedded in a while loop. This is from learn to code the hard way and I'm trying to give the user 3 chances to enter a number, where on the 3rd chance it exits using the dead function. (the comments were for my own sake)</p>

<pre><code>def gold_room():
    print "this room is full of gold. How much do you take?"
    chance = 0 #how many chances they have to type a number
    while True: #keep running
        next = raw_input("&gt; ")
        try:
            how_much = int(next) #try to convert input to number
            break #if works break out of loop and skip to **
        except: #if doesn't work then
            if chance &lt; 2: #if first, or second time let them try again
                chance += 1
                print "Better type a number..."
            else: #otherwise quit
                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!")

def dead(why):
    print why, "Good bye!"
    exit(0)
</code></pre>
