题解 | #遍历字典#
遍历字典
https://www.nowcoder.com/practice/0315639767824323a2cdb9ee3f998314
print("Here is the original dict:")
operators_dict={'<':'less than','==':'equal'}
#operators_dict=sorted(operators_dict.items(),key=lambda x:x[1])
for k,v in operators_dict.items():
print(f"Operator {k} means {v}.")
new_dict={">":"greater than"}
operators_dict.update(new_dict)
#operators_dict=sorted(operators_dict.items(),key=lambda x:x[1])
print()
print("The dict was changed to:")
for k,v in operators_dict.items():
print(f"Operator {k} means {v}.")
这题有问题呀,排序的话返回列表,不排序能通过
查看11道真题和解析
