【发布时间】:2015-01-29 06:01:49
【问题描述】:
所以我试图做到这一点,以便我可以键入多个字符串,它将连接所有字符串。但是每次它只返回一个字符串而不添加它们。
def addWords():
s = 'a'
while s != '':
s = input( ' I will echo your input until you enter return only: ')
return(s)
a = a + s
return (a)
【问题讨论】:
-
(a) 你的缩进搞砸了,(b)
return s立即终止函数。 -
在你准备好之前不要返回!
-
而有问题的代码根本无法工作。
标签: python string concatenation