Q:

Codecademy Python lesson: It's Okay to be Average

I'm stuck with this excercise:
tyler = {
    "name": "Tyler",
    "homework": [0.0, 87.0, 75.0, 22.0],
    "quizzes": [0.0, 75.0, 78.0],
    "tests": [100.0, 100.0]
}

# Add your function below!

def average(lst):
    for item in lst:
        if lst[item] == float:
            print sum(lst[item]) / len(lst[item])

average(tyler)

Why can't I get all three averages printed out?
Does the loop break when it gets to a string key in the dictionary?
How can I get only float averages printed out?

A:

if lst[item] == float:

This line looks in the dictionary for lst[item] - however all the values in your dictionary are either strings or lists. Hence, the value of the logical expression above is always False. 
Instead, use:
if type(lst[item]) == list:

I also think if you are going to iterate over a dictionary, not calling it 'lst' would be better. 
def average(lst):
    return sum(lst)/len(lst)

for key, value in tyler.iteritems():
    if type(value) == list:
        print average(value)

