【发布时间】:2018-09-15 03:41:22
【问题描述】:
请参阅以下 2 个列表:
如果我将猫及其年龄附加到两个不同的列表中,我如何对其进行排序,以便在打印最老猫的年龄时,也打印卢克,而在打印最小猫的年龄时,罗尼也被打印出来。
cats = ["ronny", "brodie", "fraise", "luke"]
age = [5, 6, 7, 11]
age.sort()
print("The age of the oldest cat is {}. This cat is {}".format(age[-1],
cats[THE OLDEST CAT]))
print("The age of the youngest cat is {}. This cat is {}".format(age[0],
cats[THE YOUNGEST CAT]))
我该怎么做?
【问题讨论】:
标签: python python-3.x list