函数名称:doubleWords
函数描述:该函数将接受一个单词列表作为参数,并将每个单词加倍。
函数签名:doubleWords(wordList: List[str]) -> List[str]
参数:
返回值:
示例代码(Python):
def doubleWords(wordList):
doubledList = []
for word in wordList:
doubledList.append(word + word)
return doubledList
示例调用:
words = ["hello", "world", "cloud", "computing"]
doubledWords = doubleWords(words)
print(doubledWords)
输出结果:
['hellohello', 'worldworld', 'cloudcloud', 'computingcomputing']
优化思路:
def doubleWords(wordList):
return [word + word for word in wordList]
应用场景:
腾讯云相关产品推荐:
领取专属 10元无门槛券
手把手带您无忧上云