def greeting(userid): try: return 'Hi %s!' % name_for_userid[userid] except KeyError: return 'Hi there'