gpt4 book ai didi

python - python 中的 max - 错误缺少 1 个必需的位置参数 : 'b'

转载 作者:太空宇宙 更新时间:2023-11-04 08:58:49 25 4
gpt4 key购买 nike

<分区>

我正在尝试在 python 上做一个练习(我的版本是 python33练习内容如下:

Write a function find_longest_word1() that takes a list of words and returns the length of the longest one. Use only higher order functions.

我的尝试是:

def find_longest_word1(a):
out = max(list(map(len,a)))
print (out)
find_longest_word1(["This","is","a","listing"])

我得到的错误是:

max() missing 1 required positional argument 'b'

我已经传递了一个列表作为参数。我是否需要为 max 函数提供一些其他参数?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com