def findmax(mylist): max = mylist[0] # 先假定第一个元素是最大值 maxdict = {"max": max} for item in mylist: if item > maxdict["max"]: maxdict["max"] = item return maxdict mylist = [4, 8, 9, 3] print(findmax(mylist))