jeudi 13 août 2015

Looping and returning all values in a dictionary

Whenever I execute the code below it only returns one total_hours instead of all hours in the value arrays

worker_hours = {'John': [8,8,4,3,8],
                'Leo': [5,6,7,8,9],
                'Sammy': [4,5,6,8,8],
                'Ken': [8,8,8,8,8]}

def calc_check(worker_list):
    worker = ''
    total_hours = 0
    for worker in worker_list:
        total_hours = sum(worker_list[worker]) * 13
    return total_hours

print(calc_check(worker_hours))



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire