# Homework 北中南東四區的PM2.5 平均值 ```python=+ L = {'北部地區': ['新北市','桃園市','臺北市', '新竹市', '新竹縣', '基隆市'], '中部地區':['彰化縣', '南投縣', '臺中市', '苗栗縣'], '南部地區':['屏東縣', '臺南市', '高雄市', '雲林縣', '嘉義市', '嘉義縣', '澎湖縣', '金門縣', '連江縣'], '東部地區':['臺東縣', '宜蘭縣', '花蓮縣']} def mean(cities, col): s = [] for i in cities: df1 = df.loc[df["county"] == i, [col]] s.append(df1[col].mean()) return s for i in L: print(i) print(round(sum(mean(L[i],"pm2.5"))/len(L[i]),2)) ``` ![](https://i.imgur.com/Zz5KO30.png)