TypeError: unsupported operand type(s) for +: 'int' and 'dict'


#1

What is wrong here

`lloyd = {
"name": "Lloyd",
"homework": [90.0, 97.0, 75.0, 92.0],
"quizzes": [88.0, 40.0, 94.0],
"tests": [75.0, 90.0]
}
alice = {
"name": "Alice",
"homework": [100.0, 92.0, 98.0, 100.0],
"quizzes": [82.0, 83.0, 91.0],
"tests": [89.0, 97.0]
}
tyler = {
"name": "Tyler",
"homework": [0.0, 87.0, 75.0, 22.0],
"quizzes": [0.0, 75.0, 78.0],
"tests": [100.0, 100.0]
}
students = [lloyd, alice, tyler]

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


#2

Here is my code that worked:
lloyd = {
"name": "Lloyd",
"homework": [90.0, 97.0, 75.0, 92.0],
"quizzes": [88.0, 40.0, 94.0],
"tests": [75.0, 90.0]
}
alice = {
"name": "Alice",
"homework": [100.0, 92.0, 98.0, 100.0],
"quizzes": [82.0, 83.0, 91.0],
"tests": [89.0, 97.0]
}
tyler = {
"name": "Tyler",
"homework": [0.0, 87.0, 75.0, 22.0],
"quizzes": [0.0, 75.0, 78.0],
"tests": [100.0, 100.0]

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

You don't need total = total/len(numbers) and average(students). Also, you have an next to average(students), which shouldn't be there.


#3

Your code itself is correct, but you don't have to call the function itself at that exercise.

You can delete this part and it should work fine:

What you are doing there is, to sum up the whole dictionary with itself. To call it correctly, you would have to call the values in the lists and then sum it up, but as I said, you don't have to do it. :slightly_smiling:


#4

It was my misstake, off course I shouldn't call function.
Thanks for helping!


#5

Thank you:slightly_smiling: