题解 | #姓名与学号#

姓名与学号

http://www.nowcoder.com/practice/ab68195587de46c59e2d327a4942d345

NP29 姓名与学号

思路:

按照要求对应创建字典,列表;for循环逐个打印即可;

代码如下:

my_dict_1 = {'name':'Niuniu','Student ID':1}
my_dict_2 = {'name':'Niumei','Student ID':2}
my_dict_3 = {'name':'Niu Ke Le','Student ID':3}
dict_list = []
dict_list.append(my_dict_1)
dict_list.append(my_dict_2)
dict_list.append(my_dict_3)
for i in dict_list:
    print("{}'s student id is {}.".format(i['name'],i['Student ID']))
全部评论
i应该是一个字典吧,dict_list是({})形式,即元素是字典的队列
点赞 回复 分享
发布于 2024-03-01 17:22 广东

相关推荐

06-26 15:33
青岛工学院 Java
积极的秋田犬要冲国企:他现在邀请我明天面试
点赞 评论 收藏
分享
程序员小白条:找的太晚,别人都是大三实习,然后大四秋招春招的,你大四下了才去实习,晚1年
点赞 评论 收藏
分享
评论
20
3
分享

创作者周榜

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