Python 3.x 关于python的家庭作业帮助
如何在python中实现这一点 您将要编写的第一个函数应称为“wordsala”。你的函数应该是4 参数,所有字符串。函数应该返回一个1字符串,格式如下:“I love” 还有,还有。” 示例测试用例: 单词沙拉“鲍勃”,“乔”,“柠檬水”,“比萨饼” 返回 我喜欢鲍勃和乔配柠檬水和比萨饼Python 3.x 关于python的家庭作业帮助,python-3.x,Python 3.x,如何在python中实现这一点 您将要编写的第一个函数应称为“wordsala”。你的函数应该是4 参数,所有字符串。函数应该返回一个1字符串,格式如下:“I love” 还有,还有。” 示例测试用例: 单词沙拉“鲍勃”,“乔”,“柠檬水”,“比萨饼” 返回 我喜欢鲍勃和乔配柠檬水和比萨饼 def wordSalad(a,b,c,d): return "I love "+a+" and "+b+" with "+c+" and "+d+'.' 试试这个。您只需要连接字符串。也可以使用字
def wordSalad(a,b,c,d):
return "I love "+a+" and "+b+" with "+c+" and "+d+'.'
试试这个。您只需要连接字符串。也可以使用字符串格式
def wordSalad(a,b,c,d):
return 'I love {} and {} with {} and {}.'.format(a,b,c,d)
除了@whackamadoodles的答案,您还可以使用%s。少打字
def wordSalad(a, b, c, d):
return 'I love %s and %s with %s and %s.' % (a, b, c, d)
你试过什么?你为什么需要帮助?你试过问你的导师吗?