I have a list in list that look like this
[['a', 9] , ['b', 1] , ['c', 4] , . . ., ['z', 2]]
From here, I want to print out each list in the list line by line to look like this
['a',9]
['b',1]
.
.
['z',2]
I knew that I can just use loop to print it out like this:
for i in list:
print(i)
but my question here is that, can it be done without using loop? Like just a one line that print this without interacting with loop. (I plan to use with some alert function so I want it to be in one large message containing all list , not multiple message with one list each)
I have tried this:
print(list, sep='\n')
but it doesn't separate into one line per list. I also tried this:
print('\n'.join(list))
and this error occured:
TypeError: sequence item 0: expected str instance, list found
which seem not to work with a list in list. Any idea?
print('\n'.join(map(str, list)))printto your function? E.g. does your function also support theprint(*lines)syntax?'\n'.joinshould work, though. depending on how your chat works, you could also tryprint(..., file=your_chat_stream)