Trying to understand returning more than one return statement with an AND operator

I’ve been tasked with the following:

Let’s return to Calvin Coolidge’s Cool College . 120 credits aren’t the only graduation requirement, you also need to have a GPA of 2.0 or higher. Rewrite the graduation_reqs function so it takes two inputs, gpa and credits , and checks to see if a student meets both requirements using an and statement. If they do, return the string “You meet the requirements to graduate!”

Here is my code:

def graduation_reqs(credits, gpa):
  if credits >= 120:
    return "You have enough credits to graduate!"
  if credits >= 120 and gpa >= 2.0:
    return "You meet the requirements to graduate!"

I’m really not sure if I can include the AND statement in the first condition because it is asking me to do a second return statement. Maybe I’m misunderstanding the question.

Could you post a link to the lesson?

Currently your second if will never evaluate to True because if credits >= 120 evaluates to True then the first if will run, and if it evaluates to False then the second if is going to be False too.

2 Likes

My guess is that your second if statement, the one with the AND, is all you need to solve the exercise. It seems to me like your first if only checking credits can be deleted or commented out.

2 Likes

https://www.codecademy.com/paths/computer-science/tracks/cspath-flow-data-iteration/modules/dspath-control-flow/lessons/python-control-flow/exercises/boolean-operators-and

I guess, I’m a bit confused because it states that I need two different returns

That was it, I was a bit confused on the directions, thank you for clearing that up.

2 Likes