Codewars notes -Seence Smash
Solution
def smash(words): sentence = "" for i in words: sentence = sentence + ' ' + i #在每个单词前加一个空格 return sentence.strip(' ') #strip('a') 去掉字符串首尾的 字符 #参数'a' 是目标要去掉的字符 smash(["hello", "world"]) smash(["hello", "amazing", "world"]) smash(["this", "is", "a", "really", "long", "sentence"])