Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with try, raise, except

Status
Not open for further replies.

Trevoke

Programmer
Jun 6, 2002
1,142
US
I'm following this book : And I'm up to chapter 11 (my bank account is fine, thanks). Could you look over this code and tell me where I'm going wrong?
It gives me the except: print all the time, and it doesn't even get as far as "Check 1 : x = "..

Code:
def inputnumber():
    x = input('Pick a number: ')
    if x == 17:
        raise 'BadNumberError', '17 is a bad number'
    print "Check 1 : x = ",x
    return x

def gimme():
    try:
        a = inputnumber()
    except:
        print "God doesn't like you today"

gimme()

Tao Te Ching Discussions : Chapter 4 (includes links to previous chapters)
 
Works fine for me.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top