Python Compare months list with base list and show the two

0

I have a list of months from January to December. I have another list that has the month and a value. For example:

Jan = 12.00

Fev = 15.00

Ago = 10.00

I want to show all year and show every month. Months that have no value should appear as 0.

    
asked by anonymous 22.08.2016 / 23:25

1 answer

0

I suppose it's something like this:

meses = ['jan', 'fev', 'mar', 'abr', 'mai', 'jun', 'jul', 
                         'ago', 'set', 'out', 'nov', 'dez']

valores = {'jan' : 12, 'fev' : 15, 'ago' : 10}

for mes in meses:
    if mes in valores:
        v = valores.get(mes)
    else:
        v = 0

    print(mes + " " + str(v))
    
23.08.2016 / 04:35