python - List Comprehension for 2-D arrays -
i have generate 2-d array list comprehension. 1 way accomplish follows
size=6 [[0] * size x in range(0, size)]
however variable x
unused here. there way accomplish this? don't want utilize external libraries.
python allows utilize _
variable name. it's pythonic utilize name unused variables:
[[0] * size _ in range(0, size)]
python
No comments:
Post a Comment