[Tutor] Problem with Exception Error
alan.gauld at blueyonder.co.uk
Sun Aug 22 22:41:59 CEST 2004
> I know I am doing this wrong but I can't figure out how to
> get it to raise the error so that it will print out
> "You must type y or n!"
There is no error. At least, not so far as Python is concerned,
so the except never gets executed. Try a simple else statement:
yn = raw_input("\r\nWhould you like to play again? ")
if yn == 'y': # might try: if yn in 'yY' instead
elif yn == 'n': # and elif yn in 'nN'
print "Thank you for playing!"
print "You must type y or n!"
More information about the Tutor