List replication operator
Ben Finney
ben+python at benfinney.id.au
Thu May 24 19:26:24 EDT 2018
Paul <tallpaul at gmail.com> writes:
> 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 = [[], [], [], [], []]
The expressions in a comprehension are evaluated each time through. So
this is another way to get that result:
foo = [ [] for __ in range(5) ]
--
\ “We now have access to so much information that we can find |
`\ support for any prejudice or opinion.” —David Suzuki, 2008-06-27 |
_o__) |
Ben Finney
More information about the Python-list
mailing list