#建立一個空字典
highScore = {}
#加入內容
highScore['會計']=6
highScore['國文']=3
highScore['英文']=5
highScore['程式']=8
#顯示字典
print(highScore)
{'會計': 6, '國文': 3, '英文': 5, '程式': 8}
#建立一個空字典
highScore = {'會計':6, '國文':3, '英文':5, '程式':8}
#刪除內容
k = '國文'
if k in highScore:
del highScore[k]
#顯示字典
print(highScore)
{'會計': 6, '英文': 5, '程式': 8}
#建立一個空字典
highScore = {'會計':6, '國文':3, '英文':5, '程式':8}
#取出並刪除內容
n = highScore.pop('國文', 0)
#顯示取出值及字典
print(n)
print(highScore)
3
{'會計': 6, '英文': 5, '程式': 8}