python local variable referenced before assignment

Solutions on MaxInterview for python local variable referenced before assignment by the best coders in the world

showing results for - "python local variable referenced before assignment"
Amy
23 Sep 2018
1def calculate_grade(grade):
2	if grade > 80:
3		letter = "A"
4	elif grade > 70:
5		letter = "B"
6	elif grade > 60:
7		letter = "C"
8	elif grade > 50:
9		letter = "D"
10	return letter
Clara
11 Jun 2020
1def calculate_grade(grade):
2	if grade > 80:
3		letter = "A"
4	elif grade > 70:
5		letter = "B"
6	elif grade > 60:
7		letter = "C"
8    elif grade > 50:
9        letter = "D"
10    else:
11        letter = "F"
12    return letter