如何将字符串添加到空变量以生成一个长单词?

How can i add strings to an empty variable to make a long word?

所以..我想把列表中的所有对象放在一起,我的想法是创建一个什么都没有的变量,然后做一个for循环来将字符串添加到变量中……但它没有没用 :( 有什么帮助吗?

我搜索了答案,但在网上找不到任何东西...我很菜鸟,如果有误,请见谅。

sounds = ["super", "cali", "fragil", "istic", "expi", "ali", "docious"]
x=""
for s in sounds:
    x+s
print(x)

我预计 x 最后会是 "supercalifragilisticexpialidocious"。

您可以使用 join:

sounds = ["super", "cali", "fragil", "istic", "expi", "ali", "docious"]

x = "".join(sounds)

print(x)

至于您的解决方案,您缺少 =:

sounds = ["super", "cali", "fragil", "istic", "expi", "ali", "docious"]
x=""
for s in sounds:
    x += s
print(x)

你得到同样的结果:

supercalifragilisticexpialidocious