落尘烟雨
2023-11-28 11:28
# Enter a code d = {"Alice": 45, "Bob": 60, "Candy": 75, "David": 86, "Ellena": 49} print(d.get("Alice", "None")) # dict.get(key,默认返回值),不指定默认返回值则默认返回None print(d.get("Bob", "None")) print(d.get("Candy", "None")) print(d.get("Mimi", "None")) print(d.get("David", "None"))
d = {
'Alice': 45,
'Bob': 60,
'Candy': 75,
'David': 86,
'Ellena': 49
}
names = ['Alice', 'Bob', 'Candy', 'Mimi', 'David']
for item in names:
print('{} score:{}'.format(item,d.get(item)))
Python3 入门教程(新版)
154161 学习 · 1075 问题
相似问题