7. Sending A Letter


#1

I’ve been going through the course again to brush up, and im stuck at this exercise

https://www.codecademy.com/courses/learn-python/lessons/student-becomes-the-teacher/exercises/sending-a-letter?action=lesson_resume

it gives me the following error:

TypeError: can’t multiply sequence by non-int of type ‘float’

def average(numbers):
  total = sum(numbers)
  return float(total) / len(numbers)

def get_average(student):
  homework = average(student["homework"])
  quizzes = average(student["quizzes"])
  tests = student["tests"]
  return homework * 0.1 + quizzes * 0.3 + tests * 0.6

def get_letter_grade(score):
  if score >= 90:
    return "A"
  elif score >= 80:
    return "B"
  elif score >= 70:
    return "C"
  elif score >= 60:
    return "D"
  else:
    return "F"
  
print get_letter_grade(get_average(lloyd))


#2

Hi @ragingblasian,

You have this in the get_average function …

  tests = student["tests"]

That assigns a list to tests.

Here, the Python interpreter detects a problem related to that assignment, namely the TypeError

  return homework * 0.1 + quizzes * 0.3 + tests * 0.6

#3

Oh wow thanks, such a silly error! sometimes the most obvious errors are the hardest to see, maybe I just need to sleep!


#4