Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a new line in list?

Tags:

python

list

I want to make a new line when making list.

I have tried this code in order to make a chart with list.

[[[] for i in range(3)] for i in range(4)]

[[[], [], []], [[], [], []], [[], [], []], [[], [], []]]

But what I want to print out is

[[[], [], []], 
[[], [], []], 
[[], [], []], 
[[], [], []]]

and I have no idea how to add '\n' in this code.. THANK YOU:)

like image 672
Jieun Avatar asked Mar 04 '23 13:03

Jieun


1 Answers

Use pprint:

>>> from pprint import pprint
>>> pprint([[[] for i in range(3)] for i in range(4)], width=30)
[[[], [], []],
 [[], [], []],
 [[], [], []],
 [[], [], []]]
>>> 
like image 55
U12-Forward Avatar answered Mar 14 '23 22:03

U12-Forward