【发布时间】:2021-11-05 13:31:50
【问题描述】:
我有这个功能,但我试图让它尽可能短。类似于:返回 [result(result += word[0]) for word in text]。基本上是一行,但是好像不行。
def first_letter(text):
text = text.upper().split()
result = ''
for word in text:
result += word[0]
return result
【问题讨论】:
标签: python python-3.x string