|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
Implement a function that receives a string, and lets you extend it with repeated calls. When no argument is passed you should return a string consisting of space-separated words you've received earlier.
Note: there will always be at least 1 string; all inputs will be non-empty.
For example:
- create_message("Hello")("World!")("how")("are")("you?")() == "Hello World! how are you?"
复制代码
我的解答:
- def create_message(s):
- strings = []
- def _msg(string=None):
- if string is None:
- return " ".join(strings)
- strings.append(string)
- return _msg
-
- return _msg(s)
复制代码 |
|