0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Python 二重リストの操作

Last updated at Posted at 2020-02-10

#二重リストの操作について

Pythonでコードを組んでいて
二重リストを扱うことがあったのでメモ。

array = [[0, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10, 11], ... ] 

配列の中に配列がある…
しかも、1行で表示されていて見づらい…

これを数学の行列みたいに
「かっこ」や「,」を取り除きたい!

print(*array, sep = '\n')

おまじないでこうしてあげると…

[0, 1, 2]
[3, 4, 5]
[6, 7, 8]
[9, 10, 11]
[0, 0, 0]

行列っぽくなった。

for a in array:
    print(*a)

こうすると

0 1 2
3 4 5
6 7 8
9 10 11
0 0 0

もっと行列っぽくなった!!

0
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?