Else If Statements - Python

Why do I get an error syntax? I’m not sure when and how “return” should be used.


def grade_converter(gpa):
  grade = ""
  if gpa >= 4.0:
    return grade = "A"
  elif gpa >= 3.0:
    return grade = "B"
  elif gpa >= 2.0:
    return grade = "C"
  elif gpa >= 1.0:
    return grade = "D"
  elif gpa >= 0.0:
    return grade = "F"  


Not sure what this has to do with else if?

anyway, you can’t do return and assignment (=) on the same line. Why would you want this? You return the value, so the assignment is pointless.

1 Like