I’ve just started to learn how to code and finished this section but wanted to test out your code to see if it worked any better and it appears to be broken on my end? the code I entered for this module here:
def applicant_selector(gpa, ps_score, ec_count):
if gpa >= 3.0 and ps_score >= 90 and ec_count >= 3:
return "This applicant should be accepted."
# printed if applicant meets all three criteria
elif gpa >= 3.0 and ps_score >= 90 and ec_count <= 2:
return "This applicant should be given an in-person interview."
else:
return "This applicant should be rejected."
print(applicant_selector(3.1, 91, 3))
print(applicant_selector(3.1, 91, 2))
print(applicant_selector(3.1, 89, 2))
When I imported your code I received a few errors and even after some trail and error they didnt work for me, but I liked what you did and modified my code to the following
def applicant_selector2(gpa, ps_score, ec_count):
if gpa >= 3.0 and ps_score >= 90:
if ec_count >= 3:
return "This applicant should be accepted."
# printed if applicant meets all three criteria
elif ec_count <= 2:
return "This applicant should be given an in-person interview."
else:
return "This applicant should be rejected."
print(applicant_selector(3.1, 91, 3))
print(applicant_selector(3.1, 91, 2))
print(applicant_selector(3.1, 89, 2))
Instead of two ‘else’ statements, i used ‘elif’ and ‘else’. This definitely saves on re-writing lines, thanks!
Edit: I played around with it a little more and finally figured out how the lines should be indented.
def
if
if
return
else
return
else
return
is how it should be.