def is_valid(to_check): """ >>> ValidateGender.is_valid('male') ('M', True) >>> ValidateGender.is_valid('female') ('F', True) >>> ValidateGender.is_valid('person') ('Person', False) >>> ValidateGender.is_valid('Gi344#@$@#$rl') ('F', True) >>> ValidateGender.is_valid('') ('INVALID', False) >>> ValidateGender.is_valid(' 789 ') ('INVALID', False) """ result = False gender_list_m = ['M', 'Boy', 'Male', 'Dude', 'Guy'] gender_list_f = ['F', 'Girl', 'Female', 'Lady'] g = to_check g = Wa.wash_all_but_string_characters(g) g = Wa.set_case(g) if g == '': g = "INVALID" elif Va.is_in_list(g, gender_list_m): g = 'M' result = True elif Va.is_in_list(g, gender_list_f): g = 'F' result = True return g, result
def is_valid(to_check): """ >>> ValidateBmi.is_valid('Obese') ('Obesity', True) >>> ValidateBmi.is_valid('norm3123123#@$@#$#@4al') ('Normal', True) >>> ValidateBmi.is_valid('person') ('Person', False) >>> ValidateBmi.is_valid('Normal') ('Normal', True) >>> ValidateBmi.is_valid('') ('INVALID', False) >>> ValidateBmi.is_valid(' ') ('INVALID', False) """ result = False list_bmi = ['Obesity', 'Overweight', 'Normal', 'Underweight'] g = to_check g = Wa.wash_all_but_string_characters(g) g = Wa.set_case(g) if g == '': g = "INVALID" if g == 'Obese': g = 'Obesity' if Va.is_in_list(g, list_bmi): result = True return g, result