2024-09-27 02:17:53 发布
网友
我有下面的字典。如果我想打印如下输出,我应该如何用python编写它
John is 20 years old with GPA 3.3. Shannon is 21 years old with GPA 3.4. Eileen is 20 years old with GPA 3.5.
students = { 101: ["John", 20, 3.3], 102: ["Shannon", 21, 3.4], 103: ["Eileen", 20, 3.5] }
你可以试试这个
for data in students.values(): print(data[0], "is ", data[1], "years old with GPA ", data[2])
这是可行的解决方案
students = { 101: ["John", 20, 3.3], 102: ["Shannon", 21, 3.4], 103: ["Eileen", 20, 3.5] } for i in students.values(): print(i[0]+" "+str(i[1])+" years old with GPA "+str(i[2]))
你可以试试这个
这是可行的解决方案
相关问题 更多 >
编程相关推荐