Print list without brackets in a single row

前端 未结 12 1349
北恋
北恋 2020-11-22 17:01

I have a list in Python e.g.

names = [\"Sam\", \"Peter\", \"James\", \"Julian\", \"Ann\"]

I want to print the array in a single line withou

12条回答
  •  执笔经年
    2020-11-22 17:58

    print(*names)

    this will work in python 3 if you want them to be printed out as space separated. If you need comma or anything else in between go ahead with .join() solution

提交回复
热议问题