Created
January 30, 2022 22:04
-
-
Save md2perpe/8d34410465d5e059ee3528d81b5150ad to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' ** PYTHON CODE CHALLENGE - SCHOOL ADMISSIONS ** ' | |
# write code to handle admissions for a school - print results | |
# rules: pass test and interview. If applicant is legacy | |
# passing either test or interview is enough to be admitted | |
# your output should be sorted | |
# output = 'Accepted students: An, Bo, Mo, My, Xi' | |
appl =['Jay','Sam','Vi','Li','My','Xi','On','Mo','An','Bo'] | |
test_ok =['xi','my','sam','an','mo','on'] | |
int_ok =['my','li','an','mo','bo','jay'] | |
legacy = ['sue','bo','xi'] | |
def accepted(person): | |
key = person.lower() | |
passed_test = key in test_ok | |
passed_int = key in int_ok | |
if key in legacy: | |
return passed_test or passed_int | |
else: | |
return passed_test and passed_int | |
accepted_students = sorted(person for person in appl if accepted(person)) | |
output = f"Accepted students: {', '.join(accepted_students)}" | |
print(output) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment