Learn Python 3: Boolean Operators: not

The code I wrote:

def graduation_reqs(gpa, credits):
  if (gpa >= 2.0) and (credits >= 120):
    return "You meet the requirements to graduate!"
  if not (credits >= 120):
    return "You do not have enough credits to graduate."
  if not (gpa >= 2.0):
    return "Your GPA is not high enough to graduate."
  if (gpa < 2.0) and (credits < 120):
    return "You do not meet either requirement to graduate!"

The Solution to the exercise: 
def graduation_reqs(gpa, credits):
  if (gpa >= 2.0) and (credits >= 120):
    return "You meet the requirements to graduate!"
  if (gpa >= 2.0) and not (credits >= 120):
    return "You do not have enough credits to graduate."
  if not (gpa >= 2.0) and (credits >= 120):
    return "Your GPA is not high enough to graduate."
  if not (gpa >= 2.0) and not (credits >= 120):
    return "You do not meet either requirement to graduate!"

So I don’t know why my code wasn’t marked as right. I tested my code and it does the same thing as the solution that Code Academy gave me. Can anyone help and/or explain?
https://www.codecademy.com/courses/learn-python-3/lessons/python-control-flow/exercises/boolean-operators-not
I put the link to my exercise.

Hello @core3960884724 welcome to the forums! I think why CC didn’t mark it as right is because of this:

It wants you to make sure that only the credits (or GPA, in the next if) is too low. In your code, the GPA could be too low, or the correct amount, with the credits too low, and this statement would still be used.
I hope this helps!

1 Like

Ohhhhhh, I get it.
Thank you!

1 Like