else statement is invariably connected the immediately preceding
if statement; in this case:
if not (gpa >= 2.0) and (credits >= 120):. The series of
if statements is to ensure the
returned string is the most useful information possible. Perhaps it’d read a little better with a chain of
elif style statements but I’d not worry about it too much for this lesson. You’re looking to learn control flow for now, a lot of the coding will sometimes seem clunky and odd to try and keep it limited to concepts already introduced.
It’s fair to say the language used in that string is perhaps a little ambiguous (or at least for those of us who aren’t grammar experts such as myself) but for me personally that reads as an inclusive or in English (“you do not meet the GPA and you do not meet the credit requirement”). Potentially rephrased with a little less ambiguity as: “You meet neither the required GPA nor the credit requirements for graduation”. It may read that way entirely due to the context in which it is placed though so I’d always advocate for less ambiguity.
Were it placed immediately following the first
if statement then that particular string wouldn’t quite make sense in my head: “You do not meet the GPA or the credit requirement for graduation.”. And if it were an exclusive statement I’d personally rephrase it as: “You do not meet the GPA requirements or you do not meet the credit requirements”, which seems less ambiguous to me.
That’s at least how it read to me and why using the
return only when the other possibilities had been exhausted made more sense.
Since the requirements state the exact string “If a student is failing to meet both graduation requirements” then to
return that string then that’s what you’ll need to do regardless of the contents of the string. Just act like it’s a client’s request and get it done. When it comes to sections where you can do your own projects and make your own choices then you can make it nice and clear and wholly unambiguous.