On Tue, Jun 19, 2012 at 3:35 PM, Selby Rowley-Cannon <selbyrowleycan...@ymail.com> wrote: > Mailing list; > I have a small, [for the most part] functioning translation app for > Rydish, a language created for the sole purpose of an RPG. The only problem > is when I enter a word that has not yet been translated, I get this error: > > Traceback (most recent call last): > File "translator.py", line 25, in <module> > Etranslate() > File "translator.py", line 14, in Etranslate > print(Edictionary[Eword]) > KeyError: 'world' > > Is there a way to print a user-freindly message instead of displaying a > traceback? > Thanks, > -Selby > > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > try: print(Edictionary[Eword] except KeyError: print Eword, " has not yet been translated"
If you catch the exception you can print a useful message. Not sure what that would be but I took a stab -- Joel Goldstick _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor