7. Sending a Letter

  1. Sending a Letter

In this exercise I initially wrote the following code:

def get_letter_grade(score):
if score >= 90:
return "A"
elif score >= 80 and < 90:
return "B"
elif score >= 70 and < 80:
return "C"
elif score >= 60 and < 70:
return "D"
return "F"
It returned an error message in which the and was markes as invalid syntax. I added this parte beacause I tought that without it there would be an overlap of grades for each letter. i.e. 79 woul return both D and C since it is greater than 60 and 70.
The code without the and part worked and did not creat this overlap. I'd like to know why and why the former syntax was invalid.



The variable needs to be referenced in both operands.

score >= 80 and score < 90


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