How to print 2D list in a single line with Python

1 Answer

0 votes
elements = [[1, 2, 3, 4], [5, 6], [7, 8, 9]]

for row in elements:
    print(' '.join([str(col) for col in row]))


'''
run:

1 2 3 4
5 6
7 8 9

'''

 



answered Oct 25, 2018 by avibootz

Related questions

1 answer 156 views
2 answers 230 views
1 answer 167 views
1 answer 211 views
1 answer 148 views
...