【发布时间】:2018-05-23 03:32:21
【问题描述】:
所以我一直试图让它工作一段时间。我试图让这些字典通过一个函数列出两个字典中的所有值,如果这有意义的话。它运行但是它只打印两个字典的最终值的行。
dictionary = {
"grades": "O",
"grades": "E",
"grades": "A",
"grades": "P",
"grades": "D",
"grades":"T",
}
dictionary_means = {
"means": "O is for Outstanding! You're top level now!",
"means": "E is for Exceeds Expectations! Very well done, almost
perfect!",
"means": "A for Acceptable. That's okay, hopefully it'll get you
somewhere...",
"means": "P is for Poor. Is that the best you can do?",
"means": "D is for Dreadful. Well at least it's not T...",
"means": "T is for Troll. Wow, you're an idiot."
}
def owls_grades (grades):
for v in grades.values():
print("Your grade is {}. ".format(v))
def owls_means (means):
for value in means.values():
print ("{}".format(value))
print (owls_grades(dictionary))
print (owls_means(dictionary_means))
【问题讨论】:
标签: python function loops dictionary