For Python in Sentence中的循环

use*_*216 2 python python-2.7

有人可以告诉我如何循环这些地方,而不是通过继续附加到字符串的字符串列出它.

world = ["Japan", "China", "Seattle", "Brazil"]

print "This is my story of the following places: " 

for place in world:
    print place
Run Code Online (Sandbox Code Playgroud)

编辑:我在打印命令的末尾添加了一个逗号,但由于它是一个单独的列表,我更喜欢,如果我能够添加一个分隔符.最终结果我希望它显示如下:

This is my store of the following places. Japan, China, Seattle, Brazil.
Run Code Online (Sandbox Code Playgroud)

最终编辑:使用以下代码,它会删除一行,我正在尝试找出如何删除附加行,以便它继续在同一行.

world = ["Japan", "China", "Seattle", "Brazil"]


print "This is my story of the following places: ", 

for i in range(0,len(world)):
    if i==(len(world)-1):
        print world[i] + '.'
    else:
        print world[i] +',',

print ". Which has all 
Run Code Online (Sandbox Code Playgroud)

这是我访问过以下地方的故事.他们是中国,日本,西雅图和巴西

.其中包含了所有伟大的图标

ILo*_*oon 6

使用该join()方法获取要与给定字符串连接的事物列表

print "This is my store of the following places. " + ", ".join(world)
Run Code Online (Sandbox Code Playgroud)