List replication operator

MRAB python at mrabarnett.plus.com
Thu May 24 19:31:18 EDT 2018


On 2018-05-25 00:05, Paul wrote:
> How would one make a multi-dimensional list now, with truly-separate sub
> lists?  Is there just no way to do it with the replication operator? IE,
> would I just have to do
>    X = [[], [], [], [], []]
> 
> or perhaps write a function to insert new sub lists into a list, or...?
> 
For a list of 5 separate lists:

X = [[] for _ in range(5)]



More information about the Python-list mailing list