题解 | #遍历字典#

遍历字典

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}.")

这题有问题呀,排序的话返回列表,不排序能通过

全部评论

相关推荐

驼瑞驰_招募评论官版...:把对方打入公司库是吧
点赞 评论 收藏
分享
酷酷的喜马拉雅山:感觉这比一直在初筛不动的好多了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务