Good!
A final word. If you put empty lines at some places it will improve the readability of the code. Some doc strings also.
A question. Why are you keep checking for
A final word. If you put empty lines at some places it will improve the readability of the code. Some doc strings also.
A question. Why are you keep checking for
pollution >=50
when you said:Quote:I have to define a function that returns for each city the number of days when pollution was above 50.
def number_of_polluted_days(januar): """Counting the days with pollution > 50""" k = {} for day, data in januar.items(): for city, pollution in data.items(): if city not in k: k[city]=0 if pollution >=50: k[city] += 1 return k def average(januar): """Calculate the average pollution""" k = {} for day, data in januar.items(): for city, pollution in data.items(): if city in k: k[city].append(pollution) else: k[city]= k[city].append(pollution) for city in k: k[city] = sum(k[city])/len(k[city]) return k