字典操作(2)
有人覺得惡作劇很好玩,動了你辛苦建立的字典。經過修改的 europe 字典已經放在指令碼中。
你能把它整理回來嗎?不要去改動 europe 的定義本身,而是請在指令碼中加入 Python 指令來更新與移除鍵值配對。
本練習屬於課程
Python 中級
練習說明
- 德國的首都不是
'bonn',而是'berlin'。請更新它的值。 - Australia 不在歐洲,Austria 才在!請從
europe中移除鍵'australia'。 - 列印
europe,確認你的清理是否成功。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Definition of dictionary
europe = {'spain':'madrid', 'france':'paris', 'germany':'bonn',
'norway':'oslo', 'italy':'rome', 'poland':'warsaw',
'australia':'vienna' }
# Update capital of germany
# Remove australia
# Print europe