Allenlax
2020-10-18 06:49
# coding=utf-8
d = {'Alice': [50, 61, 66], 'Bob': [80, 61, 66], 'Candy': [88, 75, 90]}
for key, value in d.items():
for index in range(len(value)):
print("{}的第{}次成绩是{}分".format(key,index+1,value[index]))
# Enter a code
d = {'Alice': [50, 61, 66], 'Bob': [80, 61, 66], 'Candy': [88, 75, 90]}
for key in d.keys():
for score in d[key]:
print(key, score)
for i in d.items():
if i[1] <= 60:
print(i[0])
d = {'Alice': [50, 61, 66], 'Bob': [80, 61, 66], 'Candy': [88, 75, 90]}
for item in d.items():
for score in item[1]:
print(item[0] +':' + str(score))
d = {'Alice': [50, 61, 66], 'Bob': [80, 61, 66], 'Candy': [88, 75, 90]}
for key in d:
print(key)
value =d[key]
print(value)
d = {'Alice': [50, 61, 66], 'Bob': [80, 61, 66], 'Candy': [88, 75, 90]}
print(len(d.keys()))
不用循环,d.key()获取所有元素,再len()获取长度就行了
Python3 入门教程(新版)
154175 学习 · 1075 问题
相似问题