raise ValueError('%r is not a valid scoring value. ' - 'Valid options are %s' - % (scoring, sorted(scorers))) + 'For Valid options use sorted(SCORERS.keys())' + % (scoring)) By doing this, new error message is 'ValueError: 'rubbish' is not a valid scoring value. For Valid options use sorted(SCORERS.keys())'