1. Learn
  2. /
  3. Courses
  4. /
  5. Python 中级

Connected

Exercise

字典操作(1)

如果您会访问字典,也就可以为其中的键重新赋值。要向 europe 添加一个新的键-值对,您可以这样做:

europe['iceland'] = 'reykjavik'

Instructions

100 XP
  • 向 europe 添加键 'italy',其值为 'rome'。
  • 为了验证 'italy' 现在已是 europe 的一个键,打印 'italy' in europe。
  • 再向 europe 添加一个键:值对:键为 'poland',对应的值为 'warsaw'。
  • 打印 europe。