Why doesn't this perform every if?

I test a code like this, and the result came out as “B”. I was wondering why result shows only as “B”, instead of “B C D E F” since each if statement is independent, and it meets gpa>3.0, gpa>2.0, gpa>1.0,gpa>0.0 conditions? Please help
def grade_converter(gpa):
if gpa>=4.0:
return “A”
if gpa>=3.0:
return “B”
if gpa>=2.0:
return “C”
if gpa>=1.0:
return “D”
return “F”

I believe this is because you are using the “return” statement multiple times in your function.

To my knowledge, (bear with me as I’m also a beginner) once the “return” statement is passed, the script immediately ends execution of the current function, which is probably why “C”, “D”, and “F” aren’t appearing.

If you were to remove those extra returns and set grade = “A”, grade = “B”… grade = “F” and at the end function “return grade”, you should be able to achieve the multiple grade outputs.


That is exactly the result to expect. We only want a single letter return, not a list of letters. What would give one that idea, and then write this code? We code toward the outcome we desire, without guessing. We are at the controls. A function to output a list of letters would not have to go to the length we have here.

gotcha! Thanks for the reply!