My code gets a list of numbers (grades) from the user and finds the average based on the numbers the user has given. After finding the average, I want to turn the average into a letter based grade. For example, a 90 average would return "A" and 80 would return "B".
The problem is that I can't use the result (the average) from the calculated_average(x)
function and use it at assign_grade()
.
Any tips?
#Gets a list of numbers from user
def get_score():
score_list = []
keep_going = 'y'
while keep_going == 'y':
score = float(input('Enter a test score: '))
while score < 0:
print('Positive numbers only')
score = float(input('Enter a test score: '))
score_list.append(score)
keep_going = input("More scores (y/n) ")
return score_list
#Calculates the average
def calculated_average(x):
return sum(x) / len(x)
def assign_grade():
def main():
score = get_score()
print(calculated_average(score))
main()