Why doesn't my code pass?

Hey everyone, I’m just struggling to figure out why my solution to this exercise isn’t working. My solution was this:


In the given solution, the elif statement on line 12 was ‘ec_count < 3’ instead of my not statement. Other than that they were the same.

I can’t figure out why it didn’t work my way. Any help would be great!

To avoid repeating those numbers, I used three variables inside the function:

def applicant_selector (gpa, ps_score, ec_count):
gpa_ok >= 3.0
ps_score_ok >= 90
ec_count_ok >= 3
if (gpa_ok == True) and (ps_score_ok == True) and (ec_count_ok == True):
return “This applicant should be accepted.”
elif (gpa_ok == True) and (ps_score_ok == True) and (ec_count_ok == False):
return “This applicant should be given an in-person interview.”
return “This applicant should be rejected.”


Hi orafaelporto, I like your code, very innovative!

I would suggest making the following change though, otherwise it produces an error. That is because the function in its original format never actually makes a reference to the inputs (gpa, ps_score, ec_count) inside the function.

gpa_ok = gpa >= 3.0
ps_score_ok = ps_score >= 90
ec_count_ok = ec_count >= 3

I hope this helps!

1 Like

I see. You may need to check the grammar“elif”. In my opinion,“elif” is used in the situation,“The following conditions are included in the above definition”.Thus , exchanging it will be helpful.

When return is used in each conditional branch we don’t need elif, just if on the next conditional. Likewise, no else is needed, either, just a final return.

if ____:
    return ...
if ____:
    return ...
return ...
1 Like

can you send a screnshot ? I have been trying your style and its says gpa_ok not defined