[Tutor] Problem with Exception Error
Max
spamhole at gmx.at
Sun Aug 22 21:26:52 CEST 2004
On Sunday 22 August 2004 19:04, Kevin wrote:
> How would I fix this to get it to work
> the way I want it to?
Instead of the try/except, just use an else:
> def YesNo():
> while True:
> yn = raw_input("\r\nWhould you like to play again? ")
> if yn == 'y':
> game()
> elif yn == 'n':
> print "Thank you for playing!"
> break
> else:
> print "You must type y or n!"
This way, if yn is neither 'y' nor 'n' it will print "You must type y or n!".
hth, Max
More information about the Tutor
mailing list