d = {
'Alice': 45,
'Bob': 60,
'Candy': 75,
'David': 86,
'Ellena': 49
}
if 'Alice' in d.keys():
print('Alice old score is ' + str(d['Alice']))
d['Alice'] = 60
print('Alice new score is ' + str(d['Alice']))
old_score = d.get('Alice') d['Alice'] = 60 print(old_score)
d = {
'Bob': 60,
'Candy': 75,
'Dadid':86,
'Ellena':49
}
if d.get('Alice') != None:
alice = d.get('Alice')
print(d.get('Alice'))
d['Alice']=60
print(d)
else:
d['Alice']=60
这段代码怎么什么都打印不出来,麻烦各位同学帮忙看下!
# Enter a code
d = {
'Alice': [45],
'Bob': 60,
'Candy': 75,
'David': 86,
'Ellena': 49
}
if 'Alice' in d:
print('Alice old score is ' + str(d.get('Alice')[0:len(d.get('Alice'))]))
d['Alice'].append(60)
print('Alice new score is ' + str(d['Alice'][-1]))