I have a list of publishers
publishers = ['Avatar Press', 'DC Comics', 'Dargaud', 'Dynamite Entertainment', 'Go! Comi', 'Hachette Partworks Ltd.', 'Hakusensha', 'Marvel', 'N/A', 'Planeta DeAgostini', 'Shi Bao Wen Hua Chu Ban Qi Ye Gu Fen You Xian Gong Si', 'VIZ Media']
How do I print all the publishers on their own line without a for loop like so:
for publisher in publishers:
print(publisher)
Cheers,
CodePudding user response:
try this :)
print(*publishers, sep='\n')
the *
here unpacks the list publishers
so it is equivalent to this sudo code below
print(publishers[0], publishers[1], ..., publishers[n], sep='\n')
and the sep='\n'
specifies the separator to use, in this case, a new line character
CodePudding user response:
You can concatenate the list with a new line character (\n
):
print("\n".join(publishers))