high_order #19
Replies: 2 comments 1 reply
-
查找最长的单词我们可以利用 max() 这个高阶函数简化程序逻辑: input_string = "Pythora is an amazing planet to live on"
# 将字符串按空格分割成单词列表
words = input_string.split()
# 使用max函数找到最长的单词
longest_word = max(words, key=len)
print(longest_word) |
Beta Was this translation helpful? Give feedback.
0 replies
-
这里应该错了吧,"\n"布尔值是true,也会输出 |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
high_order
列表推导式
https://py.qizhen.xyz/high_order
Beta Was this translation helpful? Give feedback.
All reactions