Python outputs the data in the list in one column

Today, when I was watching the python2 tutorial, I saw this paragraph. The data in the list is output in one column. The implementation is

for item in ['e-mail','net','homework','chat']:
    print item,
    print

Said that it is enough to add a comma after the item,
but I tried it like this, and found that it didn’t work.

for item in ['e-mail','net','homework','chat']:
    print (item,)

The output of e-mail
net
homework
chat
is still in columns.

The final idea is to replace the newline character with a space at the end of each list element output, so that it can be output as a line.

for item in ['e-mail','net','homework','chat']:
    print (item,end=' ')

e-mail net homework chat

Guess you like

Origin blog.csdn.net/qq_37823979/article/details/107653859