Https://www.codecademy.com/courses/learn-python-3/lessons/python-control-flow/exercises/else-statements

https://www.codecademy.com/courses/learn-python-3/lessons/python-control-flow/exercises/else-statements

Hi, in this can I use the following code?:

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

else:
return “You do not meet the GPA or the credit requirement for graduation.”

So, if someone doesn’t meet either or both the requirements, he would get the message “You do not meet the GPA or the credit requirement for graduation.”, instead of writing extra lines of code mentioning other conditions.
According to me, this should work if either one or both the conditions are unmet. Is that correct?

Would work if all you want to do is check to make sure that both gpa and credits are over 2.0 and 120 respectively.

This topic was automatically closed 18 hours after the last reply. New replies are no longer allowed.