How to append new line to the list

Based on what’s in your question, this will do what you’re looking for:

a = [[1], [2], [3]]
print('[')
for elem in a:
    print(elem)
    print(" ")
print(']')

Leave a Comment